| 12345678910111213141516171819202122232425262728293031323334 |
- import API, {instance} from 'packs/frontend/api';
- import MockAdapter from 'axios-mock-adapter';
- describe('API', (): void => {
- const mock = new MockAdapter(instance);
- afterAll(
- (): void => {
- mock.restore();
- }
- );
- describe('API.Pokemon', (): void => {
- describe('index()', (): void => {
- it('returns the response', async (): Promise<any> => {
- 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)', (): void => {
- it('returns the response', async (): Promise<any> => {
- 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);
- });
- });
- });
- });
|