test(web): api/index.jsx

This commit is contained in:
Paul Armstrong
2021-02-11 07:13:21 -08:00
committed by Blake Blackshear
parent 53288d361c
commit 6d133ef724
5 changed files with 136 additions and 7 deletions

View File

@@ -12,3 +12,11 @@ Object.defineProperty(window, 'matchMedia', {
dispatchEvent: jest.fn(),
}),
});
window.fetch = () => Promise.resolve();
beforeEach(() => {
jest.spyOn(window, 'fetch').mockImplementation(async (url, opts = {}) => {
throw new Error(`Unexpected fetch to ${url}, ${JSON.stringify(opts)}`);
});
});