Skip to content

Commit 914c7fa

Browse files
committed
Getting coverage up to 100% and testing for errors
1 parent c42c3c0 commit 914c7fa

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
coverage
12
node_modules

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
.DS_Store
22
.gitignore
3+
coverage
34
src
45
tests
56
yarn.lock

tests/index.test.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,28 @@ fetch.mockResponses(
1212
[ new Error('404 Not Found'), { status: 404 } ]
1313
);
1414

15-
const mockFetch = fetchMultiple(mockUrls);
15+
const resolvingFetch = fetchMultiple(mockUrls);
16+
17+
fetch.mockReject('404 Not Found');
18+
const failingFetch = fetchMultiple({ '/undefined.text': 'text' });
1619

1720
it('works as a promise', () => {
18-
expect(mockFetch.resolves);
21+
expect(resolvingFetch.resolves);
1922
});
2023

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 => {
2326
return data === {
2427
'/data.json': { data: true },
2528
'text.txt': 'Some example text'
2629
}
2730
}));
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+
}));
2839
});

0 commit comments

Comments
 (0)