@@ -3,7 +3,7 @@ import expect from 'expect.js';
33import FetchMock , { Mock } from '../src' ;
44
55const fetch = new FetchMock ( require ( '../__mocks__' ) , {
6- delay : 2000 , // delay 5s
6+ delay : 200 , // delay 200ms
77 fetch : require ( 'isomorphic-fetch' ) ,
88 exclude : [
99 'https://www.amazon.com' ,
@@ -173,23 +173,23 @@ describe('test fetch mock', () => {
173173 it ( 'global delay' , async ( ) => {
174174 const start = new Date ( ) . getTime ( ) ;
175175 await fetch ( '/api/users' ) ;
176- expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 2000 ) ;
176+ expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 199 ) . lessThan ( 210 ) ;
177177 } ) . timeout ( 20000 ) ;
178178
179179 it ( 'method delay 30ms' , async ( ) => {
180180 const start = new Date ( ) . getTime ( ) ;
181181 await fetch ( '/api/users' , {
182182 delay : 30 ,
183183 } ) ;
184- expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 30 ) ;
184+ expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 29 ) . lessThan ( 40 ) ;
185185 } ) . timeout ( 20000 ) ;
186186
187187 it ( 'method delay 3000ms' , async ( ) => {
188188 const start = new Date ( ) . getTime ( ) ;
189189 await fetch ( '/api/users' , {
190190 delay : 3000 ,
191191 } ) ;
192- expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 3000 ) ;
192+ expect ( new Date ( ) . getTime ( ) - start ) . to . greaterThan ( 2999 ) . lessThan ( 3100 ) ;
193193 } ) . timeout ( 20000 ) ;
194194
195195 } ) ;
0 commit comments