Skip to content

Commit

Permalink
Getting coverage up to 100% and testing for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
seancrater committed Feb 21, 2018
1 parent c42c3c0 commit 914c7fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
coverage
node_modules
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.DS_Store
.gitignore
coverage
src
tests
yarn.lock
19 changes: 15 additions & 4 deletions tests/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,28 @@ fetch.mockResponses(
[ new Error('404 Not Found'), { status: 404 } ]
);

const mockFetch = fetchMultiple(mockUrls);
const resolvingFetch = fetchMultiple(mockUrls);

fetch.mockReject('404 Not Found');
const failingFetch = fetchMultiple({ '/undefined.text': 'text' });

it('works as a promise', () => {
expect(mockFetch.resolves);
expect(resolvingFetch.resolves);
});

it('returns the correct values', () => {
expect(mockFetch.then(data => {
it('returns the correct values for functional endpoints', () => {
expect(resolvingFetch.then(data => {
return data === {
'/data.json': { data: true },
'text.txt': 'Some example text'
}
}));
});

it('returns an error for failing endpoints', () => {
expect(failingFetch.then(data => {
return data === {
'/undefined.text': '404 Not Found'
}
}));
});

0 comments on commit 914c7fa

Please sign in to comment.