(expr: string, date: Date, expected: any)
| 38 | }); |
| 39 | |
| 40 | const assertNextTimeInfo = (expr: string, date: Date, expected: any) => { |
| 41 | const actual = nextTimeInfo(expr, date); |
| 42 | const result = { |
| 43 | next: actual.next.toFormat(actual.format), |
| 44 | once: actual.once, |
| 45 | }; |
| 46 | |
| 47 | // 1) 失败时讯息包含 expr / expected / actual |
| 48 | // 2) 用 soft,方便一次看到多笔失败(可选) |
| 49 | expect |
| 50 | .soft( |
| 51 | result, |
| 52 | [ |
| 53 | "", |
| 54 | "", |
| 55 | `expr: ${expr}`, |
| 56 | `date: ${date.toISOString()}`, |
| 57 | `expected: ${JSON.stringify(expected)}`, |
| 58 | `actual: ${JSON.stringify(result)}`, |
| 59 | "", |
| 60 | "", |
| 61 | ].join("\n") |
| 62 | ) |
| 63 | .toEqual(expected); |
| 64 | }; |
| 65 | |
| 66 | describe.concurrent("nextTimeDisplay ERROR SAFE", () => { |
| 67 | it.concurrent.each([ |
no test coverage detected