File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ import test from 'ava' ;
2
+
3
+ import { Substitute , Arg } from '../../src/index' ;
4
+
5
+ interface IData { serverCheck : Date , data : { a : any [ ] } }
6
+ interface IFetch { getUpdates : ( arg : Date | null ) => Promise < IData > }
7
+
8
+ test ( 'issue 36 - promises returning object with properties' , async t => {
9
+ const emptyFetch = Substitute . for < IFetch > ( ) ;
10
+ const now = new Date ( ) ;
11
+ emptyFetch . getUpdates ( null ) . returns ( Promise . resolve < IData > ( {
12
+ serverCheck : now ,
13
+ data : { a : [ 1 ] }
14
+ } ) ) ;
15
+ const result = await emptyFetch . getUpdates ( null ) ;
16
+ t . true ( result . serverCheck instanceof Date , 'given date is instanceof Date' ) ;
17
+ t . is ( result . serverCheck , now , 'dates are the same' ) ;
18
+ t . true ( Array . isArray ( result . data . a ) , 'deep array isArray' ) ;
19
+ t . deepEqual ( result . data . a , [ 1 ] , 'arrays are deep equal' ) ;
20
+ } ) ;
You can’t perform that action at this time.
0 commit comments