Skip to content
Snippets Groups Projects
Commit 87df88b0 authored by Camille Villa's avatar Camille Villa
Browse files

Add tests for new action and reducer


Co-Authored-By: default avatarChris Beer <chris@cbeer.info>
parent a9d4b59a
No related branches found
No related tags found
No related merge requests found
...@@ -15,20 +15,24 @@ describe('window actions', () => { ...@@ -15,20 +15,24 @@ describe('window actions', () => {
id: 'helloworld', id: 'helloworld',
canvasIndex: 1, canvasIndex: 1,
collectionIndex: 0, collectionIndex: 0,
companionWindowIds: [],
manifestId: null, manifestId: null,
maximized: false, maximized: false,
rangeId: null, rangeId: null,
thumbnailNavigationPosition: 'bottom', thumbnailNavigationPosition: 'bottom',
x: 2700, x: 2700,
y: 2700, y: 2700,
sideBarPanel: 'info',
width: 400, width: 400,
height: 400, height: 400,
rotation: null, rotation: null,
view: 'single', view: 'single',
}, },
companionWindows: [{ position: 'left', content: 'info' }],
}; };
expect(actions.addWindow(options)).toEqual(expectedAction); const action = actions.addWindow(options);
expect(action).toMatchObject(expectedAction);
expect(action.window.companionWindowIds.length).toEqual(1);
expect(action.window.companionWindowIds[0]).toEqual(action.companionWindows[0].id);
}); });
}); });
......
...@@ -20,6 +20,22 @@ describe('companionWindowsReducer', () => { ...@@ -20,6 +20,22 @@ describe('companionWindowsReducer', () => {
}); });
}); });
describe('ADD_WINDOW', () => {
it('adds default companion window(s)', () => {
const action = {
type: ActionTypes.ADD_WINDOW,
companionWindows: [{ id: 'banana', position: 'left', content: 'info' }, { id: 'Banane', position: 'right', content: 'canvas_navigation' }],
};
const beforeState = {};
const expectedState = {
banana: { id: 'banana', position: 'left', content: 'info' },
Banane: { id: 'Banane', position: 'right', content: 'canvas_navigation' },
};
expect(companionWindowsReducer(beforeState, action)).toEqual(expectedState);
});
});
describe('UPDATE_COMPANION_WINDOW', () => { describe('UPDATE_COMPANION_WINDOW', () => {
it('updates an existing companion window', () => { it('updates an existing companion window', () => {
const action = { const action = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment