|
1 | 1 | import { describe, expect, it } from "vitest"; |
2 | | -import { checkSilenceUpdate, cleanFileName, stringMatching } from "./utils"; |
| 2 | +import { aNow, checkSilenceUpdate, cleanFileName, stringMatching } from "./utils"; |
3 | 3 | import { ltever, versionCompare } from "@App/pkg/utils/semver"; |
4 | 4 | import { nextTime } from "./cron"; |
5 | 5 | import dayjs from "dayjs"; |
6 | 6 |
|
| 7 | +describe.concurrent("aNow", () => { |
| 8 | + it.sequential("aNow is Strictly Increasing", () => { |
| 9 | + const p1 = [aNow(), aNow(), aNow(), aNow(), aNow(), aNow()]; |
| 10 | + expect(p1[0]).lessThan(p1[1]); |
| 11 | + expect(p1[1]).lessThan(p1[2]); |
| 12 | + expect(p1[2]).lessThan(p1[3]); |
| 13 | + expect(p1[3]).lessThan(p1[4]); |
| 14 | + expect(p1[4]).lessThan(p1[5]); |
| 15 | + const p2 = [...p1].sort(); |
| 16 | + expect(p1).toEqual(p2); |
| 17 | + }); |
| 18 | + it.sequential("t1 > t2 (busy) and t3 = t4 (idle)", async () => { |
| 19 | + const _p1 = [aNow(), aNow(), aNow(), aNow(), aNow(), aNow()]; |
| 20 | + const t1 = aNow(); |
| 21 | + const t2 = Date.now(); |
| 22 | + expect(t1).greaterThan(t2); |
| 23 | + await new Promise((resolve) => setTimeout(resolve, 10)); |
| 24 | + const t3 = aNow(); |
| 25 | + const t4 = Date.now(); |
| 26 | + expect(t3).toEqual(t4); |
| 27 | + }); |
| 28 | +}); |
| 29 | + |
7 | 30 | describe.concurrent("nextTime", () => { |
8 | 31 | const date = new Date(1737275107000); |
9 | 32 | it.concurrent("每分钟表达式", () => { |
|
0 commit comments