123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import React from 'react';
- import {PanelAlert} from 'app/components/panels';
- import {mount} from 'enzyme';
- import FeatureDisabled from 'app/components/acl/featureDisabled';
- describe('FeatureDisabled', function() {
- const routerContext = TestStubs.routerContext();
- it('renders', function() {
- const wrapper = mount(
- <FeatureDisabled
- features={['organization:my-features']}
- featureName="Some Feature"
- />,
- routerContext
- );
- expect(
- wrapper
- .find('FeatureDisabledMessage')
- .first()
- .text()
- ).toEqual(
- expect.stringContaining('This feature is not enabled on your Sentry installation.')
- );
- expect(wrapper.exists('HelpButton')).toBe(true);
- });
- it('renders with custom message', function() {
- const customMessage = 'custom message';
- const wrapper = mount(
- <FeatureDisabled
- message={customMessage}
- features={['organization:my-features']}
- featureName="Some Feature"
- />,
- routerContext
- );
- expect(
- wrapper
- .find('FeatureDisabledMessage')
- .first()
- .text()
- ).toEqual(expect.stringContaining(customMessage));
- });
- it('renders as an Alert', function() {
- const wrapper = mount(
- <FeatureDisabled
- alert
- features={['organization:my-features']}
- featureName="Some Feature"
- />,
- routerContext
- );
- expect(wrapper.exists('Alert')).toBe(true);
- });
- it('renders with custom alert component', function() {
- const wrapper = mount(
- <FeatureDisabled
- alert={PanelAlert}
- features={['organization:my-features']}
- featureName="Some Feature"
- />,
- routerContext
- );
- expect(wrapper.exists('PanelAlert')).toBe(true);
- });
- it('displays instructions when help is clicked', function() {
- const wrapper = mount(
- <FeatureDisabled
- alert
- features={['organization:my-features']}
- featureName="Some Feature"
- />,
- routerContext
- );
- wrapper.find('HelpButton').simulate('click');
- wrapper.update();
- expect(wrapper.exists('HelpDescription')).toBe(true);
- });
- });
|