-
Notifications
You must be signed in to change notification settings - Fork 0
/
articles.spec.js
19 lines (16 loc) · 793 Bytes
/
articles.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { createStore } from 'redux';
import deepFreeze from 'deep-freeze';
import { createArticle, getArticlesSortedByCreationDate, getLastModification } from './articles';
import reducer from './reducers';
describe('articles duck', () => {
test('should update last modification when an article is added', () => {
const store = createStore(reducer);
const previousState = deepFreeze(store.getState());
expect(getLastModification(previousState)).toBeNull();
expect(getArticlesSortedByCreationDate(previousState)).toHaveLength(0);
store.dispatch(createArticle('mon titre', 'mon contenu'));
const nextState = store.getState();
expect(getLastModification(nextState)).not.toBeNull();
expect(getArticlesSortedByCreationDate(nextState)).toHaveLength(1);
});
});