Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('set errors and clear errors', () => {
store.dispatch(Types.ERRORS_SET, {title: 'one'});
let errors = store.getState('errors');
expect(errors.length).toBe(1);
expect(errors[0]).toBe('title one');
store.dispatch(Types.ERRORS_CLEAR);
expect(store.getState('errors') == null).toBeTruthy();
});
});
it('fetch list', done => {
let fetchPromise = store.dispatch(Types.FETCH);
expect(store.getState('articlesLoading')).toBeTruthy();
fetchPromise.then(() => {
expect(store.getState('articlesLoading')).toBeFalsy();
expect(store.getState('articleCount')).toBe(500);
expect(store.getState('articlePageCount') >= store.getState('articleCount') / Conf.PAGE_SIZE).toBeTruthy();
expect(store.getState('articles') instanceof Array).toBeTruthy();
done();
});
});
});
it('set errors and clear errors', () => {
store.dispatch(Types.ERRORS_SET, {title: 'one'});
let errors = store.getState('errors');
expect(errors.length).toBe(1);
expect(errors[0]).toBe('title one');
store.dispatch(Types.ERRORS_CLEAR);
expect(store.getState('errors') == null).toBeTruthy();
});
});
fetchPromise.then(() => {
expect(store.getState('articlesLoading')).toBeFalsy();
expect(store.getState('articleCount')).toBe(500);
expect(store.getState('articlePageCount') >= store.getState('articleCount') / Conf.PAGE_SIZE).toBeTruthy();
expect(store.getState('articles') instanceof Array).toBeTruthy();
done();
});
fetchPromise.then(() => {
expect(store.getState('articlesLoading')).toBeFalsy();
expect(store.getState('articleCount')).toBe(500);
expect(store.getState('articlePageCount') >= store.getState('articleCount') / Conf.PAGE_SIZE).toBeTruthy();
expect(store.getState('articles') instanceof Array).toBeTruthy();
done();
});
fetchPromise.then(() => {
expect(store.getState('articlesLoading')).toBeFalsy();
expect(store.getState('articleCount')).toBe(500);
expect(store.getState('articlePageCount') >= store.getState('articleCount') / Conf.PAGE_SIZE).toBeTruthy();
expect(store.getState('articles') instanceof Array).toBeTruthy();
done();
});