debugged reducer tests
This commit is contained in:
parent
3635d669f4
commit
41ed27751e
2 changed files with 152 additions and 24 deletions
|
@ -1,6 +1,6 @@
|
|||
import reducer from '../list_adder';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
import * as actions from '../list_adder';
|
||||
import * as actions from 'soapbox/actions/lists';
|
||||
|
||||
describe('list_adder reducer', () => {
|
||||
it('should return the initial state', () => {
|
||||
|
@ -39,29 +39,29 @@ describe('list_adder reducer', () => {
|
|||
}));
|
||||
});
|
||||
|
||||
// it('should handle LIST_ADDER_LISTS_FETCH_REQUEST', () => {
|
||||
// const state = ImmutableMap({
|
||||
// accountId: null,
|
||||
//
|
||||
// lists: ImmutableMap({
|
||||
// items: ImmutableList(),
|
||||
// loaded: false,
|
||||
// isLoading: false,
|
||||
// }),
|
||||
// });
|
||||
// const action = {
|
||||
// type: actions.LIST_ADDER_LISTS_FETCH_REQUEST,
|
||||
// };
|
||||
// expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||
// accountId: null,
|
||||
//
|
||||
// lists: ImmutableMap({
|
||||
// items: ImmutableList(),
|
||||
// loaded: false,
|
||||
// isLoading: true,
|
||||
// }),
|
||||
// }));
|
||||
// });
|
||||
it('should handle LIST_ADDER_LISTS_FETCH_REQUEST', () => {
|
||||
const state = ImmutableMap({
|
||||
accountId: null,
|
||||
|
||||
lists: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
});
|
||||
const action = {
|
||||
type: actions.LIST_ADDER_LISTS_FETCH_REQUEST,
|
||||
};
|
||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||
accountId: null,
|
||||
|
||||
lists: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: true,
|
||||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
it('should handle LIST_ADDER_LISTS_FETCH_FAIL', () => {
|
||||
const state = ImmutableMap({
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import reducer from '../list_editor';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
import * as actions from 'soapbox/actions/lists';
|
||||
|
||||
describe('list_editor reducer', () => {
|
||||
it('should return the initial state', () => {
|
||||
|
@ -21,4 +22,131 @@ describe('list_editor reducer', () => {
|
|||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
it('should handle LIST_EDITOR_RESET', () => {
|
||||
const state = ImmutableMap({
|
||||
listId: null,
|
||||
isSubmitting: false,
|
||||
isChanged: false,
|
||||
title: '',
|
||||
|
||||
accounts: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
|
||||
suggestions: ImmutableMap({
|
||||
value: '',
|
||||
items: ImmutableList(),
|
||||
}),
|
||||
});
|
||||
const action = {
|
||||
type: actions.LIST_EDITOR_RESET,
|
||||
};
|
||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||
listId: null,
|
||||
isSubmitting: false,
|
||||
isChanged: false,
|
||||
title: '',
|
||||
|
||||
accounts: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
|
||||
suggestions: ImmutableMap({
|
||||
value: '',
|
||||
items: ImmutableList(),
|
||||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
it('should handle LIST_EDITOR_SETUP', () => {
|
||||
const state = ImmutableMap({
|
||||
listId: null,
|
||||
isSubmitting: false,
|
||||
isChanged: false,
|
||||
title: '',
|
||||
|
||||
accounts: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
|
||||
suggestions: ImmutableMap({
|
||||
value: '',
|
||||
items: ImmutableList(),
|
||||
}),
|
||||
});
|
||||
const action = {
|
||||
type: actions.LIST_EDITOR_SETUP,
|
||||
list: ImmutableMap({
|
||||
id: '22',
|
||||
title: 'list 1',
|
||||
}),
|
||||
};
|
||||
expect(reducer(state, action)).toEqual(ImmutableMap({
|
||||
listId: '22',
|
||||
isSubmitting: false,
|
||||
isChanged: false,
|
||||
title: 'list 1',
|
||||
|
||||
accounts: ImmutableMap({
|
||||
items: ImmutableList(),
|
||||
loaded: false,
|
||||
isLoading: false,
|
||||
}),
|
||||
|
||||
suggestions: ImmutableMap({
|
||||
value: '',
|
||||
items: ImmutableList(),
|
||||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
it('should handle LIST_EDITOR_TITLE_CHANGE', () => {
|
||||
const state = ImmutableMap({
|
||||
title: 'list 1',
|
||||
isChanged: false,
|
||||
});
|
||||
const action = {
|
||||
type: actions.LIST_EDITOR_TITLE_CHANGE,
|
||||
value: 'list 1 edited',
|
||||
};
|
||||
expect(reducer(state, action).toJS()).toMatchObject({
|
||||
isChanged: true,
|
||||
title: 'list 1 edited',
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle LIST_UPDATE_REQUEST', () => {
|
||||
const state = ImmutableMap({
|
||||
isSubmitting: false,
|
||||
isChanged: true,
|
||||
});
|
||||
const action = {
|
||||
type: actions.LIST_UPDATE_REQUEST,
|
||||
};
|
||||
expect(reducer(state, action).toJS()).toMatchObject({
|
||||
isSubmitting: true,
|
||||
isChanged: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle LIST_UPDATE_FAIL', () => {
|
||||
debugger;
|
||||
const state = ImmutableMap({
|
||||
isSubmitting: true,
|
||||
});
|
||||
const action = {
|
||||
type: actions.LIST_UPDATE_FAIL,
|
||||
};
|
||||
expect(reducer(state, action).toJS()).toMatchObject({
|
||||
isSubmitting: false,
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue