UNPKG

@cainiaofe/cn-ui-m

Version:
25 lines (24 loc) 1.29 kB
import { getFormatStrFromPrecision } from '../get-format-str-from-precision'; describe('getFormatStrFromPrecision', function () { it('should return the correct format string for day precision', function () { expect(getFormatStrFromPrecision('day')).toBe('YYYY-MM-DD'); }); it('should return the correct format string for hour precision', function () { expect(getFormatStrFromPrecision('hour')).toBe('YYYY-MM-DD HH:00:00'); }); it('should return the correct format string for minute precision', function () { expect(getFormatStrFromPrecision('minute')).toBe('YYYY-MM-DD HH:mm:00'); }); it('should return the correct format string for second precision', function () { expect(getFormatStrFromPrecision('second')).toBe('YYYY-MM-DD HH:mm:ss'); }); it('should return the correct format string for month precision', function () { expect(getFormatStrFromPrecision('month')).toBe('YYYY-MM'); }); it('should return the correct format string for year precision', function () { expect(getFormatStrFromPrecision('year')).toBe('YYYY'); }); it('should return the default format string for unknown precision', function () { expect(getFormatStrFromPrecision('unknown')).toBe('YYYY-MM-DD'); }); });