api.js refactor using classes (#250)

Refactor api.js into an api module where endpoint specific models can be imported and used in components.
This commit is contained in:
Michael Abashian
2019-06-07 15:48:09 -04:00
committed by GitHub
parent a8c51670af
commit 2ae93261d1
51 changed files with 839 additions and 727 deletions

View File

@@ -6,6 +6,10 @@ import { asyncFlush } from '../jest.setup';
import App from '../src/App';
import { RootAPI } from '../src/api';
jest.mock('../src/api');
describe('<App />', () => {
test('expected content is rendered', () => {
const appWrapper = mountWithContexts(
@@ -89,15 +93,13 @@ describe('<App />', () => {
});
test('onLogout makes expected call to api client', async (done) => {
const logout = jest.fn(() => Promise.resolve());
const appWrapper = mountWithContexts(<App />, {
context: { network: { api: { logout }, handleHttpError: () => {} } }
context: { network: { handleHttpError: () => {} } }
}).find('App');
appWrapper.instance().onLogout();
await asyncFlush();
expect(logout).toHaveBeenCalledTimes(1);
expect(RootAPI.logout).toHaveBeenCalledTimes(1);
done();
});