@cainiaofe/cn-ui-m
Version:
30 lines (29 loc) • 1.36 kB
JavaScript
import { dayjs } from "../../../../utils/dayjs";
import { getEndOfQuarter } from '../get-end-of-quarter';
describe('getEndOfQuarter', function () {
test('should return the end of the first quarter', function () {
var date = dayjs('2023-02-15');
var result = getEndOfQuarter(date);
expect(result.format('YYYY-MM-DD HH:mm:ss')).toBe('2023-03-31 23:59:59');
});
test('should return the end of the second quarter', function () {
var date = dayjs('2023-05-20');
var result = getEndOfQuarter(date);
expect(result.format('YYYY-MM-DD HH:mm:ss')).toBe('2023-06-30 23:59:59');
});
test('should return the end of the third quarter', function () {
var date = dayjs('2023-08-10');
var result = getEndOfQuarter(date);
expect(result.format('YYYY-MM-DD HH:mm:ss')).toBe('2023-09-30 23:59:59');
});
test('should return the end of the fourth quarter', function () {
var date = dayjs('2023-11-25');
var result = getEndOfQuarter(date);
expect(result.format('YYYY-MM-DD HH:mm:ss')).toBe('2023-12-31 23:59:59');
});
test('should handle leap year correctly', function () {
var date = dayjs('2024-02-29');
var result = getEndOfQuarter(date);
expect(result.format('YYYY-MM-DD HH:mm:ss')).toBe('2024-03-31 23:59:59');
});
});