From 484233e171ab97c6323b01822949fa2c9833a73f Mon Sep 17 00:00:00 2001 From: Benedikt Mehl Date: Fri, 31 Jan 2025 13:45:45 +0100 Subject: [PATCH] Fix tests #3879 --- .../services/loadFile/loadFile.service.spec.ts | 14 ++++++++------ .../ui/filePanel/fileSelectionMode.service.spec.ts | 13 +++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/visualization/app/codeCharta/services/loadFile/loadFile.service.spec.ts b/visualization/app/codeCharta/services/loadFile/loadFile.service.spec.ts index f7a30379e2..809c86d5bf 100644 --- a/visualization/app/codeCharta/services/loadFile/loadFile.service.spec.ts +++ b/visualization/app/codeCharta/services/loadFile/loadFile.service.spec.ts @@ -229,12 +229,14 @@ describe("loadFileService", () => { expect(storeDispatchSpy).toHaveBeenCalledWith(setCurrentFilesAreSampleFiles({ value: false })) expect(CCFilesUnderTest.length).toEqual(3) - expect(CCFilesUnderTest[0].fileMeta.fileName).toEqual("SecondFile") - expect(CCFilesUnderTest[0].fileMeta.fileChecksum).toEqual("hash_1") - expect(CCFilesUnderTest[1].fileMeta.fileName).toEqual("ThirdFile") - expect(CCFilesUnderTest[1].fileMeta.fileChecksum).toEqual("hash_2_1") - expect(CCFilesUnderTest[2].fileMeta.fileName).toEqual("FourthFile") - expect(CCFilesUnderTest[2].fileMeta.fileChecksum).toEqual("hash_3") + const allFileNames = CCFilesUnderTest.map(file => file.fileMeta.fileName) + expect(allFileNames).toContain("SecondFile") + expect(allFileNames).toContain("ThirdFile") + expect(allFileNames).toContain("FourthFile") + const allChecksums = CCFilesUnderTest.map(file => file.fileMeta.fileChecksum) + expect(allChecksums).toContain("hash_1") + expect(allChecksums).toContain("hash_2_1") + expect(allChecksums).toContain("hash_3") }) it("should keep sample files when loading the same sample file and after that another different file", () => { diff --git a/visualization/app/codeCharta/ui/filePanel/fileSelectionMode.service.spec.ts b/visualization/app/codeCharta/ui/filePanel/fileSelectionMode.service.spec.ts index c3c994ec50..4316f1f7f0 100644 --- a/visualization/app/codeCharta/ui/filePanel/fileSelectionMode.service.spec.ts +++ b/visualization/app/codeCharta/ui/filePanel/fileSelectionMode.service.spec.ts @@ -19,8 +19,8 @@ describe("FileSelectionModeService", () => { }) store = TestBed.inject(Store) state = TestBed.inject(State) - store.dispatch(addFile({ file: TEST_FILE_DATA })) store.dispatch(addFile({ file: TEST_FILE_DATA_JAVA })) + store.dispatch(addFile({ file: TEST_FILE_DATA })) store.dispatch(setStandard({ files: [TEST_FILE_DATA] })) fileSelectionModeService = new FileSelectionModeService(store, state) @@ -33,16 +33,16 @@ describe("FileSelectionModeService", () => { it("should restore previous files on toggle", () => { let fileStates = state.getValue().files - expect(fileStates[0].selectedAs).toBe(FileSelectionState.Partial) - expect(fileStates[1].selectedAs).toBe(FileSelectionState.None) + expect(fileStates[0].selectedAs).toBe(FileSelectionState.None) + expect(fileStates[1].selectedAs).toBe(FileSelectionState.Partial) fileSelectionModeService.toggle() store.dispatch(setDelta({ referenceFile: TEST_FILE_DATA_JAVA, comparisonFile: TEST_FILE_DATA })) - fileSelectionModeService.toggle() + fileStates = state.getValue().files - expect(fileStates[0].selectedAs).toBe(FileSelectionState.Partial) - expect(fileStates[1].selectedAs).toBe(FileSelectionState.None) + expect(fileStates[0].selectedAs).toBe(FileSelectionState.None) + expect(fileStates[1].selectedAs).toBe(FileSelectionState.Partial) }) it("should not restore a removed file when toggling back to delta mode", () => { @@ -63,6 +63,7 @@ describe("FileSelectionModeService", () => { store.dispatch(addFile({ file: file2 })) store.dispatch(addFile({ file: file3 })) + fileSelectionModeService.toggle() fileSelectionModeService.toggle() const fileStates = state.getValue().files