From 1123e294995124c42763c7078fd79d117b962ca1 Mon Sep 17 00:00:00 2001 From: Carlos Valente Date: Mon, 29 Apr 2024 21:50:19 +0200 Subject: [PATCH] fix: explicit rundown order in tests --- .../server/src/utils/__tests__/parser.test.ts | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/apps/server/src/utils/__tests__/parser.test.ts b/apps/server/src/utils/__tests__/parser.test.ts index 809226c94..70e0964da 100644 --- a/apps/server/src/utils/__tests__/parser.test.ts +++ b/apps/server/src/utils/__tests__/parser.test.ts @@ -1488,24 +1488,31 @@ describe('parseExcel()', () => { }; const result = parseExcel(testData, importMap); - const rundown = parseRundown(result); + const initialRundown = parseRundown(result); - cache.init(rundown, {}); - const cachedRundown = cache.get().rundown; + cache.init(initialRundown, {}); + const { rundown, order } = cache.get(); - const events = Object.values(cachedRundown).filter((e) => e.type === SupportedEvent.Event) as OntimeEvent[]; + const firstId = order.at(0); // A + const secondId = order.at(1); // C + const thirdId = order.at(2); // D + const fourthId = order.at(3); // E + const fifhtId = order.at(4); // Block + const sixthId = order.at(5); // G - expect(events.at(0).timeStart).toEqual(16200000); + expect((rundown[firstId] as OntimeEvent).timeStart).toEqual(16200000); - expect(events.at(1).timeStart).toEqual(events.at(0).timeEnd); - expect(events.at(1).linkStart).toEqual(events.at(0).id); + expect((rundown[secondId] as OntimeEvent).timeStart).toEqual((rundown[firstId] as OntimeEvent).timeEnd); + expect((rundown[secondId] as OntimeEvent).linkStart).toEqual((rundown[firstId] as OntimeEvent).id); - expect(events.at(2).timeStart).toEqual(events.at(1).timeEnd); - expect(events.at(2).linkStart).toEqual(events.at(1).id); + expect((rundown[thirdId] as OntimeEvent).timeStart).toEqual((rundown[secondId] as OntimeEvent).timeEnd); + expect((rundown[thirdId] as OntimeEvent).linkStart).toEqual((rundown[secondId] as OntimeEvent).id); - expect(events.at(3).timeStart).toEqual(78300000); + expect((rundown[fourthId] as OntimeEvent).timeStart).toEqual(78300000); - expect(events.at(4).timeStart).toEqual(events.at(3).timeEnd); - expect(events.at(4).linkStart).toEqual(events.at(3).id); + expect((rundown[fifhtId] as OntimeEvent).type).toEqual(SupportedEvent.Block); + + expect((rundown[sixthId] as OntimeEvent).timeStart).toEqual((rundown[fourthId] as OntimeEvent).timeEnd); + expect((rundown[sixthId] as OntimeEvent).linkStart).toEqual((rundown[fourthId] as OntimeEvent).id); }); });