1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-28 17:55:15 +02:00
unleash.unleash/frontend/src/component/strategies/__tests__/list-component-test.jsx
Fredrik Strand Oseberg dbed06f300 Feat/material UI (#250)
Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
Co-authored-by: Christopher Kolstad <chriswk@getunleash.ai>
Co-authored-by: Christopher Kolstad <git@chriswk.no>
2021-03-30 15:14:02 +02:00

57 lines
1.9 KiB
JavaScript

import React from 'react';
import { MemoryRouter } from 'react-router-dom';
import { ThemeProvider } from '@material-ui/core';
import StrategiesListComponent from '../StrategiesList/StrategiesList';
import renderer from 'react-test-renderer';
import { CREATE_STRATEGY, DELETE_STRATEGY } from '../../../permissions';
import theme from '../../../themes/main-theme';
test('renders correctly with one strategy', () => {
const strategy = {
name: 'Another',
description: "another's description",
};
const tree = renderer.create(
<MemoryRouter>
<ThemeProvider theme={theme}>
<StrategiesListComponent
strategies={[strategy]}
fetchStrategies={jest.fn()}
removeStrategy={jest.fn()}
deprecateStrategy={jest.fn()}
reactivateStrategy={jest.fn()}
history={{}}
hasPermission={permission => [CREATE_STRATEGY, DELETE_STRATEGY].indexOf(permission) !== -1}
/>
</ThemeProvider>
</MemoryRouter>
);
expect(tree).toMatchSnapshot();
});
test('renders correctly with one strategy without permissions', () => {
const strategy = {
name: 'Another',
description: "another's description",
};
const tree = renderer.create(
<MemoryRouter>
<ThemeProvider theme={theme}>
<StrategiesListComponent
strategies={[strategy]}
fetchStrategies={jest.fn()}
removeStrategy={jest.fn()}
deprecateStrategy={jest.fn()}
reactivateStrategy={jest.fn()}
history={{}}
hasPermission={() => false}
/>
</ThemeProvider>
</MemoryRouter>
);
expect(tree).toMatchSnapshot();
});