1- import chai from 'chai' ;
2- import spies from 'chai-spies' ;
31import { fromJS } from 'immutable' ;
4-
52import actionTypesFactory from '../../../../src/redux/helpers/resourceManager/actionTypesFactory.js' ;
63import actionCreatorsFactory from '../../../../src/redux/helpers/resourceManager/actionCreatorsFactory.js' ;
74
8- chai . use ( spies ) ;
9- const expect = chai . expect ;
5+ import chai from '../../../chai-spy.js' ;
106
117// prepared spies
128let globalNeedsRefetching = false ; // this is really disgusting, I know...
@@ -39,13 +35,13 @@ describe('Resource manager', () => {
3935 const { fetchResource } = actionCreators ;
4036
4137 // fetchResource must be a function with one parameter
42- expect ( fetchResource ) . to . be . a ( 'function' ) ;
43- expect ( fetchResource . length ) . to . equal ( 1 ) ;
38+ chai . expect ( fetchResource ) . to . be . a ( 'function' ) ;
39+ chai . expect ( fetchResource . length ) . to . equal ( 1 ) ;
4440
4541 // calling fetchResource will create an action through the 'createApiAction' function
4642 fetchResource ( 'abc' ) ;
47- expect ( createApiAction ) . to . have . been . called . once ;
48- expect ( createApiAction ) . to . have . been . called . with ( {
43+ chai . expect ( createApiAction ) . to . have . been . called . once ;
44+ chai . expect ( createApiAction ) . to . have . been . called . with ( {
4945 type : actionTypes . FETCH ,
5046 method : 'GET' ,
5147 endpoint : 'url/abc' ,
@@ -57,13 +53,13 @@ describe('Resource manager', () => {
5753 const { fetchOneIfNeeded } = actionCreators ;
5854
5955 // fetchResource must be a function with one parameter
60- expect ( fetchOneIfNeeded ) . to . be . a ( 'function' ) ;
61- expect ( fetchOneIfNeeded . length ) . to . equal ( 1 ) ;
56+ chai . expect ( fetchOneIfNeeded ) . to . be . a ( 'function' ) ;
57+ chai . expect ( fetchOneIfNeeded . length ) . to . equal ( 1 ) ;
6258
6359 // calling fetchResource will create a thunk
6460 const thunk = fetchOneIfNeeded ( 'abc' ) ;
65- expect ( thunk ) . to . be . a ( 'function' ) ;
66- expect ( thunk . length ) . to . equal ( 2 ) ;
61+ chai . expect ( thunk ) . to . be . a ( 'function' ) ;
62+ chai . expect ( thunk . length ) . to . equal ( 2 ) ;
6763
6864 const getState = ( ) =>
6965 fromJS ( {
@@ -76,8 +72,8 @@ describe('Resource manager', () => {
7672 const dispatch = chai . spy ( ) ;
7773 const thunkResult = thunk ( dispatch , getState ) ;
7874
79- expect ( dispatch ) . to . not . have . been . called ( ) ;
80- expect ( thunkResult . then ) . to . be . a ( 'function' ) ;
75+ chai . expect ( dispatch ) . to . not . have . been . called ( ) ;
76+ chai . expect ( thunkResult . then ) . to . be . a ( 'function' ) ;
8177 thunkResult . then ( ( ) => done ( ) ) ; // must be resolved right away
8278 } ) ;
8379
@@ -96,8 +92,8 @@ describe('Resource manager', () => {
9692 const dispatch = chai . spy ( ) ;
9793 thunk ( dispatch , getState ) ; // we don't care about the resulting state in this test
9894
99- expect ( dispatch ) . to . have . been . called . once ;
100- expect ( dispatch ) . to . have . been . called . with ( fetchResource ( 'abc' ) ) ;
95+ chai . expect ( dispatch ) . to . have . been . called . once ;
96+ chai . expect ( dispatch ) . to . have . been . called . with ( fetchResource ( 'abc' ) ) ;
10197 } ) ;
10298 } ) ;
10399
@@ -106,13 +102,13 @@ describe('Resource manager', () => {
106102 const { fetchMany } = actionCreators ;
107103
108104 // fetchResource must be a function with one parameter
109- expect ( fetchMany ) . to . be . a ( 'function' ) ;
110- expect ( fetchMany . length ) . to . equal ( 1 ) ;
105+ chai . expect ( fetchMany ) . to . be . a ( 'function' ) ;
106+ chai . expect ( fetchMany . length ) . to . equal ( 1 ) ;
111107
112108 // calling fetchResource will create an action through the 'createApiAction' function
113109 fetchMany ( { } ) ;
114- expect ( createApiAction ) . to . have . been . called . once ;
115- expect ( createApiAction ) . to . have . been . called . with ( {
110+ chai . expect ( createApiAction ) . to . have . been . called . once ;
111+ chai . expect ( createApiAction ) . to . have . been . called . with ( {
116112 type : actionTypes . FETCH_MANY ,
117113 method : 'GET' ,
118114 endpoint : 'url/' ,
@@ -124,14 +120,14 @@ describe('Resource manager', () => {
124120 it ( 'must create an "add resource" action creator' , ( ) => {
125121 const { addResource } = actionCreators ;
126122
127- expect ( addResource ) . to . be . a ( 'function' ) ;
128- expect ( addResource . length ) . to . equal ( 1 ) ;
123+ chai . expect ( addResource ) . to . be . a ( 'function' ) ;
124+ chai . expect ( addResource . length ) . to . equal ( 1 ) ;
129125
130126 const body = { foo : 'bar' , abc : 'xyz' } ;
131127 const tmpId = 'random-tmp-id' ;
132128 addResource ( body , tmpId ) ;
133- expect ( createApiAction ) . to . have . been . called . once ;
134- expect ( createApiAction ) . to . have . been . called . with ( {
129+ chai . expect ( createApiAction ) . to . have . been . called . once ;
130+ chai . expect ( createApiAction ) . to . have . been . called . with ( {
135131 type : actionTypes . ADD ,
136132 method : 'POST' ,
137133 endpoint : 'url/' ,
@@ -150,14 +146,14 @@ describe('Resource manager', () => {
150146 it ( 'must create an "update resource" action creator' , ( ) => {
151147 const { updateResource } = actionCreators ;
152148
153- expect ( updateResource ) . to . be . a ( 'function' ) ;
154- expect ( updateResource . length ) . to . equal ( 2 ) ;
149+ chai . expect ( updateResource ) . to . be . a ( 'function' ) ;
150+ chai . expect ( updateResource . length ) . to . equal ( 2 ) ;
155151
156152 const body = { foo : 'bar' , abc : 'xyz' } ;
157153 const id = 'some-id' ;
158154 updateResource ( id , body ) ;
159- expect ( createApiAction ) . to . have . been . called . once ;
160- expect ( createApiAction ) . to . have . been . called . with ( {
155+ chai . expect ( createApiAction ) . to . have . been . called . once ;
156+ chai . expect ( createApiAction ) . to . have . been . called . with ( {
161157 type : actionTypes . UPDATE ,
162158 method : 'POST' ,
163159 endpoint : `url/${ id } ` ,
@@ -171,13 +167,13 @@ describe('Resource manager', () => {
171167 it ( 'must create an "remove resource" action creator' , ( ) => {
172168 const { removeResource } = actionCreators ;
173169
174- expect ( removeResource ) . to . be . a ( 'function' ) ;
175- expect ( removeResource . length ) . to . equal ( 1 ) ;
170+ chai . expect ( removeResource ) . to . be . a ( 'function' ) ;
171+ chai . expect ( removeResource . length ) . to . equal ( 1 ) ;
176172
177173 const id = 'some-id' ;
178174 removeResource ( id ) ;
179- expect ( createApiAction ) . to . have . been . called . once ;
180- expect ( createApiAction ) . to . have . been . called . with ( {
175+ chai . expect ( createApiAction ) . to . have . been . called . once ;
176+ chai . expect ( createApiAction ) . to . have . been . called . with ( {
181177 type : actionTypes . REMOVE ,
182178 method : 'DELETE' ,
183179 endpoint : `url/${ id } ` ,
0 commit comments