diff --git a/.gitignore b/.gitignore index b512c09..7cafbdb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +coverage node_modules \ No newline at end of file diff --git a/.npmignore b/.npmignore index 71493a0..148061d 100644 --- a/.npmignore +++ b/.npmignore @@ -1,5 +1,6 @@ .DS_Store .gitignore +coverage src tests yarn.lock \ No newline at end of file diff --git a/tests/index.test.js b/tests/index.test.js index 4595f06..fbf283b 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -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' + } + })); }); \ No newline at end of file