-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add test for updateFileSettings.effect
- Loading branch information
1 parent
dcbd191
commit 5803fee
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
...ization/app/codeCharta/state/effects/updateFileSettings/updateFileSettings.effect.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { ApplicationInitStatus } from "@angular/core" | ||
import { TestBed } from "@angular/core/testing" | ||
import { Action } from "redux" | ||
import { Subject } from "rxjs" | ||
|
||
import { EffectsModule } from "../../angular-redux/effects/effects.module" | ||
import { State } from "../../angular-redux/state" | ||
import { setFiles } from "../../store/files/files.actions" | ||
import { setState } from "../../store/state.actions" | ||
import { Store } from "../../store/store" | ||
import { UpdateFileSettingsEffect } from "./updateFileSettings.effect" | ||
|
||
describe("UpdateFileSettingsEffect", () => { | ||
const mockedDialog = { open: jest.fn() } | ||
let storeDispatchSpy | ||
|
||
beforeEach(async () => { | ||
storeDispatchSpy = jest.spyOn(Store, "dispatch") | ||
mockedDialog.open = jest.fn() | ||
|
||
EffectsModule.actions$ = new Subject<Action>() | ||
TestBed.configureTestingModule({ | ||
imports: [EffectsModule.forRoot([UpdateFileSettingsEffect])], | ||
providers: [{ provide: State, useValue: { getValue: () => ({ files: [] }) } }] | ||
}) | ||
await TestBed.inject(ApplicationInitStatus).donePromise | ||
}) | ||
|
||
afterEach(() => { | ||
EffectsModule.actions$.complete() | ||
}) | ||
|
||
it("should ignore a not relevant action", () => { | ||
EffectsModule.actions$.next({ type: "whatever" }) | ||
expect(storeDispatchSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it("should not blacklist items if it would lead to an empty map but show error dialog", () => { | ||
EffectsModule.actions$.next(setFiles([])) | ||
expect(storeDispatchSpy).not.toHaveBeenCalledWith( | ||
setState({ | ||
fileSettings: { | ||
edges: [], | ||
markedPackages: [], | ||
blacklist: [], | ||
attributeTypes: {} | ||
} | ||
}) | ||
) | ||
}) | ||
}) |