test(web): api/index.jsx

This commit is contained in:
Paul Armstrong
2021-02-16 07:08:25 -06:00
committed by Blake Blackshear
parent cc93b8503b
commit 496af03be9
5 changed files with 136 additions and 7 deletions
+8
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)}`);
});
});