2021-09-04 18:11:29 +01:00
|
|
|
import { AppState } from './app.reducer';
|
2021-09-04 12:37:22 +01:00
|
|
|
import appReducer, { createAppDefaultState } from './app.reducer';
|
|
|
|
|
2023-02-20 12:02:29 -03:00
|
|
|
describe('app.reducer', () => {
|
2021-09-04 12:37:22 +01:00
|
|
|
|
2023-03-08 19:23:49 +00:00
|
|
|
it('should handle DIALOG_OPEN', async () => {
|
2021-09-04 12:37:22 +01:00
|
|
|
const state: AppState = createAppDefaultState({}, {});
|
|
|
|
|
|
|
|
let newState = appReducer(state, {
|
|
|
|
type: 'DIALOG_OPEN',
|
|
|
|
name: 'syncWizard',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(newState.dialogs.length).toBe(1);
|
|
|
|
expect(newState.dialogs[0].name).toBe('syncWizard');
|
|
|
|
|
|
|
|
expect(() => appReducer(newState, {
|
|
|
|
type: 'DIALOG_OPEN',
|
|
|
|
name: 'syncWizard',
|
|
|
|
})).toThrow();
|
|
|
|
|
|
|
|
newState = appReducer(newState, {
|
|
|
|
type: 'DIALOG_CLOSE',
|
|
|
|
name: 'syncWizard',
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(newState.dialogs.length).toBe(0);
|
|
|
|
|
|
|
|
expect(() => appReducer(newState, {
|
|
|
|
type: 'DIALOG_CLOSE',
|
|
|
|
name: 'syncWizard',
|
|
|
|
})).toThrow();
|
|
|
|
|
|
|
|
newState = appReducer(newState, {
|
|
|
|
type: 'DIALOG_OPEN',
|
|
|
|
name: 'syncWizard',
|
|
|
|
});
|
|
|
|
|
|
|
|
newState = appReducer(newState, {
|
|
|
|
type: 'DIALOG_OPEN',
|
|
|
|
name: 'setPassword',
|
|
|
|
});
|
|
|
|
|
2021-11-15 19:27:31 +00:00
|
|
|
expect(newState.dialogs).toEqual([
|
|
|
|
{ name: 'syncWizard', props: {} },
|
|
|
|
{ name: 'setPassword', props: {} },
|
|
|
|
]);
|
2021-09-04 12:37:22 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|