mirror of
https://github.com/labring/FastGPT.git
synced 2026-05-11 01:02:01 +08:00
289da0f7b0
* sandbox-sync-agent * refactor: host pro as submodule * chore: checkpoint host pro restructure * refactor workspace test layout and startup init * chore: update next turbopack setup * chore: snapshot current work before actions fix * chore: update pro submodule * chore: point pro submodule url to upstream https * fix: Dockerfile * chore: update pro submodule * ci: support private pro submodule token and skip fork jobs * fix(ci): build sdk workspace deps before code-sandbox bundle * fix(app): exclude vitest configs from production typecheck * fix(app-image): build sdk packages before next build * fix(ci): align dockerfiles with workspace sdk build flow * chore(docker): upgrade node20 docker images to node24 * fix(ci): read admin coverage output path in pro test workflow * fix(app-image): include next-i18next config and locale assets * chore: update pro submodule * chore: do not specify branch for submodule * chore: remove most ts-nocheck sign * chore: update pro submodule * chore: remove sandbox-agent-sync package * chore: do not modify "pushData" file logic * fix: health check * chore: restore dev axios proxy state * fix: test-fastgpt report workflow * fix: use valid vitest coverage action inputs
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { calculateDaysBetweenDates, getMonthRemainingDays } from '@fastgpt/global/common/math/date';
|
|
|
|
describe('calculateDaysBetweenDates', () => {
|
|
it('should return zero for same day', () => {
|
|
const date = new Date('2024-01-01T00:00:00Z');
|
|
expect(calculateDaysBetweenDates(date, date)).toBe(0);
|
|
});
|
|
|
|
it('should return absolute day difference', () => {
|
|
const date1 = new Date('2024-01-01T00:00:00Z');
|
|
const date2 = new Date('2024-01-03T00:00:00Z');
|
|
expect(calculateDaysBetweenDates(date1, date2)).toBe(2);
|
|
expect(calculateDaysBetweenDates(date2, date1)).toBe(2);
|
|
});
|
|
|
|
it('should floor partial days', () => {
|
|
const date1 = new Date('2024-01-01T00:00:00Z');
|
|
const date2 = new Date('2024-01-01T23:59:59Z');
|
|
expect(calculateDaysBetweenDates(date1, date2)).toBe(0);
|
|
});
|
|
});
|
|
|
|
describe('getMonthRemainingDays', () => {
|
|
it('should calculate remaining days in January', () => {
|
|
const startDate = new Date(2024, 0, 10, 0, 0, 0);
|
|
expect(getMonthRemainingDays(startDate)).toBe(21);
|
|
});
|
|
|
|
it('should calculate remaining days in leap February', () => {
|
|
const startDate = new Date(2024, 1, 10, 0, 0, 0);
|
|
expect(getMonthRemainingDays(startDate)).toBe(19);
|
|
});
|
|
});
|