|
4 | 4 | formatSearch,
|
5 | 5 | getDuration,
|
6 | 6 | getMimeType,
|
| 7 | + parseWorkflowDates, |
7 | 8 | } from "~/util";
|
8 | 9 |
|
9 | 10 | test.each([
|
@@ -56,3 +57,31 @@ test.each([
|
56 | 57 | ])("formatFileSize(%p) === %p", (fileSize, formattedFileSize) => {
|
57 | 58 | expect(formatFileSize(fileSize)).toEqual(formattedFileSize);
|
58 | 59 | });
|
| 60 | + |
| 61 | +test.each([ |
| 62 | + ["finished", "15 min 0 sec", { run_finished_at: "2024-01-18T08:45:00" }], |
| 63 | + ["failed", "15 min 0 sec", { run_finished_at: "2024-01-18T08:45:00" }], |
| 64 | + ["stopped", "10 min 0 sec", { run_stopped_at: "2024-01-18T08:40:00" }], |
| 65 | + ["running", "20 min 0 sec", {}], |
| 66 | + ["queued", "20 min 0 sec", {}], |
| 67 | + ["pending", "20 min 0 sec", {}], |
| 68 | + ["created", "20 min 0 sec", {}], |
| 69 | +])( |
| 70 | + `parseWorkflowDates [status: %p], duration === %p`, |
| 71 | + (status, duration, progress_override) => { |
| 72 | + const workflow = { |
| 73 | + status: status, |
| 74 | + created: "2024-01-18T08:25:00", |
| 75 | + progress: { |
| 76 | + run_started_at: "2024-01-18T08:30:00", |
| 77 | + run_stopped_at: null, |
| 78 | + run_finished_at: null, |
| 79 | + ...progress_override, |
| 80 | + }, |
| 81 | + }; |
| 82 | + |
| 83 | + jest.useFakeTimers(); |
| 84 | + jest.setSystemTime(new Date(2024, 0, 18, 8, 50, 0)); |
| 85 | + expect(parseWorkflowDates(workflow).duration).toEqual(duration); |
| 86 | + }, |
| 87 | +); |
0 commit comments