@@ -3,7 +3,7 @@ import expect from 'expect.js';
3
3
import FetchMock , { Mock } from '../src' ;
4
4
5
5
const fetch = new FetchMock ( require ( '../__mocks__' ) , {
6
- delay : 2000 , // delay 5s
6
+ delay : 200 , // delay 200ms
7
7
fetch : require ( 'isomorphic-fetch' ) ,
8
8
exclude : [
9
9
'https://www.amazon.com' ,
@@ -173,23 +173,23 @@ describe('test fetch mock', () => {
173
173
it ( 'global delay' , async ( ) => {
174
174
const start = new Date ( ) . getTime ( ) ;
175
175
await fetch ( '/api/users' ) ;
176
- expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 2000 ) ;
176
+ expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 199 ) . lessThan ( 210 ) ;
177
177
} ) . timeout ( 20000 ) ;
178
178
179
179
it ( 'method delay 30ms' , async ( ) => {
180
180
const start = new Date ( ) . getTime ( ) ;
181
181
await fetch ( '/api/users' , {
182
182
delay : 30 ,
183
183
} ) ;
184
- expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 30 ) ;
184
+ expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 29 ) . lessThan ( 40 ) ;
185
185
} ) . timeout ( 20000 ) ;
186
186
187
187
it ( 'method delay 3000ms' , async ( ) => {
188
188
const start = new Date ( ) . getTime ( ) ;
189
189
await fetch ( '/api/users' , {
190
190
delay : 3000 ,
191
191
} ) ;
192
- expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 3000 ) ;
192
+ expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 2999 ) . lessThan ( 3100 ) ;
193
193
} ) . timeout ( 20000 ) ;
194
194
195
195
} ) ;
0 commit comments