Improved existing tests

This commit is contained in:
Alejandro Celaya 2020-11-28 11:45:04 +01:00
parent 2a206f11b9
commit dc397d4b82
2 changed files with 25 additions and 0 deletions

View file

@ -60,4 +60,11 @@ describe('<Checkbox />', () => {
expect(onChange).toHaveBeenCalledWith(false, e);
});
it('allows setting inline rendering', () => {
const wrapped = createComponent({ inline: true });
const control = wrapped.find('.custom-control');
expect(control.prop('style')).toEqual({ display: 'inline-block' });
});
});

View file

@ -1,6 +1,8 @@
import { AxiosInstance, AxiosRequestConfig } from 'axios';
import ShlinkApiClient from '../../../src/utils/services/ShlinkApiClient';
import { OptionalString } from '../../../src/utils/utils';
import { Mock } from 'ts-mockery';
import { ShlinkDomain } from '../../../src/utils/services/types';
describe('ShlinkApiClient', () => {
const createAxios = (data: AxiosRequestConfig) => (async () => Promise.resolve(data)) as unknown as AxiosInstance;
@ -251,4 +253,20 @@ describe('ShlinkApiClient', () => {
expect(result).toEqual(expectedData);
});
});
describe('listDomains', () => {
it('returns domains', async () => {
const expectedData = [Mock.all<ShlinkDomain>(), Mock.all<ShlinkDomain>()];
const resp = {
domains: { data: expectedData },
};
const axiosSpy = createAxiosMock({ data: resp });
const { listDomains } = new ShlinkApiClient(axiosSpy, '', '');
const result = await listDomains();
expect(axiosSpy).toHaveBeenCalled();
expect(result).toEqual(expectedData);
});
});
});