1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-10 17:53:36 +02:00
unleash.unleash/frontend/src/component/menu/__tests__/apidetails.test.tsx
olav 74733e5b44 refactor: port ApiDetails to useSWR and TS (#653)
* refactor: add missing react-test-renderer types

* refactor: make IVersionInfo match backend type

* refactor: allow falsy conditions in ConditionallyRender

* refactor: port ApiDetails to useSWR and TS

* refactor: use arrow functions

* refactor: move useUiConfig to Footer

* refactor: add component name to props type

* refactor: move ApiDetails helpers to own file

* refactor: combine ApiDetails helper components

* refactor: move ApiDetails to the Footer dir

* Revert "refactor: allow falsy conditions in ConditionallyRender"

This reverts commit 70d75951eb4d0611e80b015a97243404618493ed.

* refactor: use booleans for ConditionallyRender

* refactor: use a subdir for ApiDetails

* refactor: fix ApiDetails helpers filename

* refactor: reformat using correct prettier settings
2022-02-02 12:32:30 +01:00

54 lines
1.4 KiB
TypeScript

import React from 'react';
import renderer from 'react-test-renderer';
import { ApiDetails } from '../Footer/ApiDetails/ApiDetails';
test('renders correctly with empty version', () => {
const uiConfig = {
name: 'Unleash',
slogan: 'We are the best!',
environment: 'test',
version: '',
};
const tree = renderer.create(<ApiDetails uiConfig={uiConfig} />).toJSON();
expect(tree).toMatchSnapshot();
});
test('renders correctly with ui-config', () => {
const uiConfig = {
name: 'Unleash',
slogan: 'We are the best!',
environment: 'test',
version: '1.1.0',
};
const tree = renderer.create(<ApiDetails uiConfig={uiConfig} />).toJSON();
expect(tree).toMatchSnapshot();
});
test('renders correctly without uiConfig', () => {
const uiConfig = {
name: 'Unleash',
version: '1.1.0',
};
const tree = renderer.create(<ApiDetails uiConfig={uiConfig} />).toJSON();
expect(tree).toMatchSnapshot();
});
test('renders correctly with versionInfo', () => {
const uiConfig = {
name: 'Unleash',
version: '1.2.3',
versionInfo: {
instanceId: '1',
isLatest: false,
current: { enterprise: '1.2.3', oss: '1.2.3' },
latest: { enterprise: '1.2.4', oss: '1.2.4' },
},
};
const tree = renderer.create(<ApiDetails uiConfig={uiConfig} />).toJSON();
expect(tree).toMatchSnapshot();
});