File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change
1
+ coverage
1
2
node_modules
Original file line number Diff line number Diff line change 1
1
.DS_Store
2
2
.gitignore
3
+ coverage
3
4
src
4
5
tests
5
6
yarn.lock
Original file line number Diff line number Diff line change @@ -12,17 +12,28 @@ fetch.mockResponses(
12
12
[ new Error ( '404 Not Found' ) , { status : 404 } ]
13
13
) ;
14
14
15
- const mockFetch = fetchMultiple ( mockUrls ) ;
15
+ const resolvingFetch = fetchMultiple ( mockUrls ) ;
16
+
17
+ fetch . mockReject ( '404 Not Found' ) ;
18
+ const failingFetch = fetchMultiple ( { '/undefined.text' : 'text' } ) ;
16
19
17
20
it ( 'works as a promise' , ( ) => {
18
- expect ( mockFetch . resolves ) ;
21
+ expect ( resolvingFetch . resolves ) ;
19
22
} ) ;
20
23
21
- it ( 'returns the correct values' , ( ) => {
22
- expect ( mockFetch . then ( data => {
24
+ it ( 'returns the correct values for functional endpoints ' , ( ) => {
25
+ expect ( resolvingFetch . then ( data => {
23
26
return data === {
24
27
'/data.json' : { data : true } ,
25
28
'text.txt' : 'Some example text'
26
29
}
27
30
} ) ) ;
31
+ } ) ;
32
+
33
+ it ( 'returns an error for failing endpoints' , ( ) => {
34
+ expect ( failingFetch . then ( data => {
35
+ return data === {
36
+ '/undefined.text' : '404 Not Found'
37
+ }
38
+ } ) ) ;
28
39
} ) ;
You can’t perform that action at this time.
0 commit comments