/*! * @license * Copyright Squiz Australia Pty Ltd. All Rights Reserved. */ import { faker } from '@faker-js/faker/locale/en'; import { createMockJobExecution } from '../../model/JobExecution'; import { sortByTimeQueued } from './SortByTimeQueued'; describe(`sortByTimeQueued`, () => { const earlierExecution = createMockJobExecution({ timeQueued: faker.date.recent().toISOString() }); const laterExecution = createMockJobExecution({ timeQueued: faker.date.soon().toISOString() }); it(`should return -1 if the first execution comes BEFORE the second execution`, () => { const result = sortByTimeQueued(earlierExecution, laterExecution); expect(result).toBe(-1); }); it(`should return 1 if the first execution comes AFTER the second execution`, () => { const result = sortByTimeQueued(laterExecution, earlierExecution); expect(result).toBe(1); }); it(`should return 0 if both executions share the same time queued`, () => { const result = sortByTimeQueued(earlierExecution, earlierExecution); expect(result).toBe(0); }); });