import API, {instance} from 'packs/frontend/api'; import MockAdapter from 'axios-mock-adapter'; describe('API', () => { const mock = new MockAdapter(instance); afterAll(() => { mock.restore(); }); describe('API.Pokemon', () => { describe('index()', () => { it('returns the response', async () => { const expected = {foo: 'bar'}; mock.onGet('/api/v1/pokemon').reply(200, expected); const response = await API.Pokemon.index(); expect(response.data).toEqual(expected); }); }); describe('get(id)', () => { it('returns the response', async () => { const expected = {id: 1, name: 'pukuchu'}; mock.onGet(`/api/v1/pokemon/${expected.id}`).reply(200, expected); const response = await API.Pokemon.get(expected.id); expect(response.data).toEqual(expected); }); }); }); });