Skip to content

Commit

Permalink
WIP - added spec for modal reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathew1011 committed May 13, 2021
1 parent 3278d04 commit eb5dac6
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions projects/wvr-elements/src/lib/core/modal/modal.reducers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
import { EntityMapOne, Update } from '@ngrx/entity';
import { actions } from '../actions';
import { Modal } from './modal';
import * as fromModalActions from './modal.actions';
import * as fromModalReducers from './modal.reducers';

describe('Modal Reducer', () => {
const modal: Modal = {
const initModal: Modal = {
name: 'Test Modal',
open: false
};

describe('initial state', () => {

it('should have an initial state', () => {
const {initialState} = fromModalReducers;
const action = {} as any;
expect(fromModalReducers.reducer(undefined, action))
.toBe(initialState);
});

it('should select manifest by name', () => {
expect(fromModalReducers.selectModalByName(modal))
.toEqual(modal.name);
expect(fromModalReducers.selectModalByName(initModal))
.toEqual(initModal.name);
});

});

const state = {ids: [], entities: {}};
const modal: Modal = {
name: 'Add a Modal',
open: false
};
const action = fromModalActions.addModal({modal});
const addReducerObj = fromModalReducers.reducer(state, action );

it(' should add modal', () => {
expect(JSON.stringify(addReducerObj.entities[modal.name].name) === JSON.stringify(modal.name) )
.toBe(true);
});

});

0 comments on commit eb5dac6

Please sign in to comment.