mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2025-01-09 01:37:24 +03:00
Improved existing tests
This commit is contained in:
parent
2a206f11b9
commit
dc397d4b82
2 changed files with 25 additions and 0 deletions
|
@ -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' });
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue