Skip to content

Commit

Permalink
Added specs for wysiwyg reducer
Browse files Browse the repository at this point in the history
  • Loading branch information
rmathew1011 committed May 14, 2021
1 parent 22a2ea3 commit d1f6b26
Showing 1 changed file with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,55 @@ describe('Wysiwyg Reducer', () => {

});

const state = {ids: [], entities: {}};
const wysiwyg: Wysiwyg = {
id: '1',
initialContent: 'Hello, World!',
content: 'Hello, World!'
};
const action = fromWysiWygActions.addWysiwyg({wysiwyg});
const addReducerObj = fromWysiwygReducers.reducer(state, action );

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

const saveWysiwygState = {
ids: [
'148'
],
entities: {
'148': {
id: '148',
initialContent: 'Hello, World!',
content: 'Hello, World!'
}
}
};

// save wysiwyg
const saveWysiwygReducerObj = fromWysiwygReducers.reducer(saveWysiwygState,
fromWysiWygActions.saveWysiwyg({id: '148', content: 'Updated Text'}));

Object.keys( saveWysiwygReducerObj['entities']['148']).forEach( key => {
if(key === 'content') {
it(' should be able to save content', () => {
expect((JSON.stringify(saveWysiwygReducerObj['entities']['148']['content']) === '"Updated Text"'))
.toBeTrue();
});
}
});

// reset wysiwyg
const resetWysiwygReducerObj = fromWysiwygReducers.reducer(saveWysiwygState,
fromWysiWygActions.saveWysiwyg({id: '148', content: 'Hello, World!'}));
Object.keys( resetWysiwygReducerObj['entities']['148']).forEach( key => {
if(key === 'content') {
it(' should be able to reset content', () => {
expect((JSON.stringify(resetWysiwygReducerObj['entities']['148']['content']) === '"Hello, World!"'))
.toBeTrue();
});
}
});
});

0 comments on commit d1f6b26

Please sign in to comment.