|
| 1 | +define([ |
| 2 | + 'jsx/collaborations/reducers/collaborationsReducer', |
| 3 | + 'jsx/collaborations/actions/collaborationsActions' |
| 4 | +], (reducer, actions) => { |
| 5 | + module('collaborationsReducer'); |
| 6 | + |
| 7 | + const defaults = reducer(undefined, {}) |
| 8 | + |
| 9 | + test('there are defaults', () => { |
| 10 | + equal(Array.isArray(defaults.collaborations), true); |
| 11 | + equal(defaults.collaborations.length, 0); |
| 12 | + equal(defaults.listCollaborationsPending, false); |
| 13 | + equal(defaults.listCollaborationsSuccessful, false); |
| 14 | + equal(defaults.listCollaborationsError, null); |
| 15 | + }); |
| 16 | + |
| 17 | + test('responds to listCollaborationsStart', () => { |
| 18 | + let state = { |
| 19 | + listCollaborationsPending: false, |
| 20 | + listCollaborationsSuccessful: true, |
| 21 | + listCollaborationsError: {} |
| 22 | + }; |
| 23 | + |
| 24 | + let action = actions.listCollaborationsStart(); |
| 25 | + let newState = reducer(state, action); |
| 26 | + equal(newState.listCollaborationsPending, true); |
| 27 | + equal(newState.listCollaborationsSuccessful, false); |
| 28 | + equal(newState.listCollaborationsError, null); |
| 29 | + }); |
| 30 | + |
| 31 | + test('responds to listCollaborationsSuccessful', () => { |
| 32 | + let state = { |
| 33 | + listCollaborationsPending: true, |
| 34 | + listCollaborationsSuccessful: false, |
| 35 | + collaborations: [] |
| 36 | + }; |
| 37 | + let collaborations = [{}]; |
| 38 | + |
| 39 | + let action = actions.listCollaborationsSuccessful(collaborations); |
| 40 | + let newState = reducer(state, action); |
| 41 | + equal(newState.listCollaborationsPending, false); |
| 42 | + equal(newState.listCollaborationsSuccessful, true); |
| 43 | + equal(newState.collaborations, collaborations); |
| 44 | + }); |
| 45 | + |
| 46 | + test('responds to listCollaborationsFailed', () => { |
| 47 | + let state = { |
| 48 | + listCollaborationsPending: true, |
| 49 | + listCollaborationsError: null |
| 50 | + }; |
| 51 | + let error = {}; |
| 52 | + |
| 53 | + let action = actions.listCollaborationsFailed(error); |
| 54 | + let newState = reducer(state, action); |
| 55 | + equal(newState.listCollaborationsPending, false); |
| 56 | + equal(newState.listCollaborationsError, error); |
| 57 | + }); |
| 58 | +}); |
0 commit comments