Skip to content

Commit

Permalink
Merge pull request #371 from TAMULib/sprint18-staging-code-coverage-t…
Browse files Browse the repository at this point in the history
…esting

Code coverage
  • Loading branch information
jeremythuff committed May 14, 2021
2 parents 7914575 + 22a2ea3 commit bbf509c
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
32 changes: 28 additions & 4 deletions projects/wvr-elements/src/lib/core/modal/modal.reducers.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
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';
Expand Down Expand Up @@ -37,9 +35,35 @@ describe('Modal Reducer', () => {
.toBe(true);
});

// close modal
// it(' should ');
const openState = {
ids: ['OpenModal'],
entities: {
'OpenModal': {
name: 'OpenModal',open: false
}
}
};

// open modal
const openModalReducerObj = fromModalReducers.reducer(openState, fromModalActions.openModal({ id: 'OpenModal' }) );

Object.keys( openModalReducerObj['entities']['OpenModal']).forEach( key => {
if(key === 'open') {
it(' should be able to open modal', () => {
expect((JSON.stringify(openModalReducerObj['entities']['OpenModal']['open']) === "true"))
.toBeTrue();
});
}
});

// close Modal
const closeModalReducerObj = fromModalReducers.reducer(openState, fromModalActions.closeModal({ id: 'OpenModal' }) );
Object.keys( closeModalReducerObj['entities']['OpenModal']).forEach( key => {
if(key === 'open') {
it(' should be able to close modal', () => {
expect((JSON.stringify(closeModalReducerObj['entities']['OpenModal']['open']) === "false"))
.toBeTrue();
});
}
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Wysiwyg } from './wysiwyg';
import * as fromWysiWygActions from './wysiwyg.actions';
import * as fromWysiwygReducers from './wysiwyg.reducers';

describe('Wysiwyg Reducer', () => {
const initWysiwyg: Wysiwyg = {
id: '1',
initialContent: 'Hello, World!',
content: 'Hello, World!'
};

describe('initial state', () => {
it('should have an initial state', () => {
const {initialState} = fromWysiwygReducers;
const action = {} as any;
expect(fromWysiwygReducers.reducer(undefined, action))
.toBe(initialState);
});
it('should select wysiwyg by id', () => {
expect(fromWysiwygReducers.selectWysiwygById(initWysiwyg))
.toEqual(initWysiwyg.id);
});

});

});

0 comments on commit bbf509c

Please sign in to comment.