Commit 8096cd8f by Torkel Ödegaard

fix: added reducer test

parent a317158b
import { Action, ActionTypes } from './actions'; import { Action, ActionTypes } from './actions';
import { FolderDTO } from 'app/types';
import { inititalState, folderReducer } from './reducers'; import { inititalState, folderReducer } from './reducers';
function getTestFolder(): FolderDTO {
return {
id: 1,
title: 'test folder',
uid: 'asd',
url: 'url',
canSave: true,
version: 0,
};
}
describe('folder reducer', () => { describe('folder reducer', () => {
it('should set teams', () => { it('should load folder and set hasChanged to false', () => {
const payload = [getMockTeam()]; const folder = getTestFolder();
const action: Action = {
type: ActionTypes.LoadFolder,
payload: folder,
};
const state = folderReducer(inititalState, action);
expect(state.hasChanged).toEqual(false);
expect(state.title).toEqual('test folder');
});
it('should set title', () => {
const action: Action = { const action: Action = {
type: ActionTypes.LoadTeams, type: ActionTypes.SetFolderTitle,
payload, payload: 'new title',
}; };
const result = teamsReducer(initialTeamsState, action); const state = folderReducer(inititalState, action);
expect(result.teams).toEqual(payload); expect(state.hasChanged).toEqual(true);
expect(state.title).toEqual('new title');
}); });
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment