From dc397d4b825a471f8a373626559cc8baf6ca0e76 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 28 Nov 2020 11:45:04 +0100 Subject: [PATCH] Improved existing tests --- test/utils/Checkbox.test.tsx | 7 +++++++ test/utils/services/ShlinkApiClient.test.ts | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/test/utils/Checkbox.test.tsx b/test/utils/Checkbox.test.tsx index f9d08d48..444924f4 100644 --- a/test/utils/Checkbox.test.tsx +++ b/test/utils/Checkbox.test.tsx @@ -60,4 +60,11 @@ describe('', () => { 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' }); + }); }); diff --git a/test/utils/services/ShlinkApiClient.test.ts b/test/utils/services/ShlinkApiClient.test.ts index b581885d..4838712f 100644 --- a/test/utils/services/ShlinkApiClient.test.ts +++ b/test/utils/services/ShlinkApiClient.test.ts @@ -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(), Mock.all()]; + 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); + }); + }); });