1
1
import moxios from 'moxios' ;
2
2
import makeMockStore from './Utils/makeMockStore' ;
3
- import { fetchResponseData , mockData } from './testData/articleData' ;
3
+ import { fetchResponseData , mockData , getArticlesByTagData } from './testData/articleData' ;
4
4
import ArticleActions from '../src/actions/ArticleActions' ;
5
5
import {
6
6
SET_LOADING ,
7
7
FETCH_ARTICLES ,
8
8
SET_CURRENT_ARTICLES ,
9
+ GET_ARTICLES_BY_TAG ,
9
10
} from '../src/actions/types' ;
10
11
11
- const { fetchArticles } = ArticleActions ;
12
+ const { fetchArticles, getArticlesByTag } = ArticleActions ;
12
13
13
14
const store = makeMockStore ( {
14
15
article : {
16
+ totalArticles : 0 ,
17
+ currentArticles : [ ] ,
18
+ articlesByTag : [ ] ,
15
19
allArticles : [ ] ,
16
20
loading : false ,
17
21
} ,
@@ -26,23 +30,25 @@ describe('Article Actions', () => {
26
30
moxios . uninstall ( ) ;
27
31
} ) ;
28
32
29
- it ( 'fetches articles' , ( ) => {
30
- moxios . wait ( ( ) => {
31
- const request = moxios . requests . mostRecent ( ) ;
32
- request . respondWith ( { status : 200 , response : fetchResponseData } ) ;
33
- } ) ;
33
+ describe ( 'fetchArticles' , ( ) => {
34
+ it ( 'fetches articles' , ( ) => {
35
+ moxios . wait ( ( ) => {
36
+ const request = moxios . requests . mostRecent ( ) ;
37
+ request . respondWith ( { status : 200 , response : fetchResponseData } ) ;
38
+ } ) ;
34
39
35
- const expectedActions = [
36
- { type : SET_LOADING } ,
37
- { type : FETCH_ARTICLES , payload : mockData } ,
38
- { type : SET_CURRENT_ARTICLES , payload : mockData . articles } ,
39
- ] ;
40
+ const expectedActions = [
41
+ { type : SET_LOADING } ,
42
+ { type : FETCH_ARTICLES , payload : mockData } ,
43
+ { type : SET_CURRENT_ARTICLES , payload : mockData . articles } ,
44
+ ] ;
40
45
41
- return store . dispatch ( fetchArticles ( ) )
42
- . then ( ( ) => {
43
- const actionsCalled = store . getActions ( ) ;
44
- expect ( actionsCalled ) . toEqual ( expectedActions ) ;
45
- expect ( actionsCalled [ 1 ] . type ) . toEqual ( FETCH_ARTICLES ) ;
46
- } ) ;
46
+ return store . dispatch ( fetchArticles ( ) )
47
+ . then ( ( ) => {
48
+ const actionsCalled = store . getActions ( ) ;
49
+ expect ( actionsCalled ) . toEqual ( expectedActions ) ;
50
+ expect ( actionsCalled [ 1 ] . type ) . toEqual ( FETCH_ARTICLES ) ;
51
+ } ) ;
52
+ } ) ;
47
53
} ) ;
48
54
} ) ;
0 commit comments