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__/strategy-details-component-test.jsx
Benjamin Ludewig 85fb0f9b89 feature: Add support for permission system in unleash frontend
refactored permission-based components
added tests for all permission-based components
2019-01-16 10:39:58 +01:00

55 lines
1.5 KiB
JavaScript

import React from 'react';
import StrategyDetails from '../strategy-details-component';
import renderer from 'react-test-renderer';
import { UPDATE_STRATEGY } from '../../../permissions';
import { MemoryRouter } from 'react-router-dom';
jest.mock('react-mdl');
test('renders correctly with one strategy', () => {
const strategy = {
name: 'Another',
description: "another's description",
editable: true,
parameters: [
{
name: 'customParam',
type: 'list',
description: 'customList',
required: true,
},
],
};
const applications = [
{
appName: 'appA',
description: 'app description',
},
];
const toggles = [
{
name: 'toggleA',
description: 'toggle description',
},
];
const tree = renderer.create(
<MemoryRouter>
<StrategyDetails
strategyName={'Another'}
strategy={strategy}
activeTab="view"
applications={applications}
toggles={toggles}
fetchStrategies={jest.fn()}
fetchApplications={jest.fn()}
fetchFeatureToggles={jest.fn()}
history={{}}
hasPermission={permission => [UPDATE_STRATEGY].indexOf(permission) !== -1}
/>
</MemoryRouter>
);
expect(tree).toMatchSnapshot();
});