Skip to content

Commit

Permalink
Fix tests #3879
Browse files Browse the repository at this point in the history
  • Loading branch information
BenediktMehl committed Jan 31, 2025
1 parent 4a9f73b commit 484233e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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", () => {
Expand All @@ -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
Expand Down

0 comments on commit 484233e

Please sign in to comment.