123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- import React from 'react';
- import {shallow, mount} from 'enzyme';
- import OrganizationAuthList from 'app/views/settings/organizationAuth/organizationAuthList';
- jest.mock('jquery');
- describe('OrganizationAuthList', function() {
- it('renders with no providers', function() {
- const wrapper = shallow(
- <OrganizationAuthList providerList={[]} />,
- TestStubs.routerContext()
- );
- expect(wrapper).toMatchSnapshot();
- });
- it('renders', function() {
- const wrapper = shallow(
- <OrganizationAuthList
- orgId="org-slug"
- onSendReminders={() => {}}
- providerList={TestStubs.AuthProviders()}
- />,
- TestStubs.routerContext()
- );
- expect(wrapper).toMatchSnapshot();
- });
- it('renders for members', function() {
- const wrapper = mount(
- <OrganizationAuthList
- orgId="org-slug"
- onSendReminders={() => {}}
- providerList={TestStubs.AuthProviders()}
- activeProvider={TestStubs.AuthProviders()[0]}
- />,
- TestStubs.routerContext([
- {
- organization: TestStubs.Organization({access: ['org:read']}),
- },
- ])
- );
- expect(wrapper.find('ProviderItem ActiveIndicator')).toHaveLength(1);
- });
- describe('with 2fa warning', function() {
- const require2fa = {require2FA: true};
- const withSSO = {features: ['sso-basic']};
- const withSAML = {features: ['sso-saml2']};
- it('renders', function() {
- const context = TestStubs.routerContext([
- {organization: TestStubs.Organization({...require2fa, ...withSSO})},
- ]);
- const wrapper = shallow(
- <OrganizationAuthList
- orgId="org-slug"
- onSendReminders={() => {}}
- providerList={TestStubs.AuthProviders()}
- />,
- context
- );
- expect(wrapper.find('PanelAlert[type="warning"]').exists()).toBe(true);
- });
- it('renders with saml available', function() {
- const context = TestStubs.routerContext([
- {organization: TestStubs.Organization({...require2fa, ...withSAML})},
- ]);
- const wrapper = shallow(
- <OrganizationAuthList
- orgId="org-slug"
- onSendReminders={() => {}}
- providerList={TestStubs.AuthProviders()}
- />,
- context
- );
- expect(wrapper.find('PanelAlert[type="warning"]').exists()).toBe(true);
- });
- it('does not render without sso available', function() {
- const context = TestStubs.routerContext([
- {organization: TestStubs.Organization({...require2fa})},
- ]);
- const wrapper = shallow(
- <OrganizationAuthList
- orgId="org-slug"
- onSendReminders={() => {}}
- providerList={TestStubs.AuthProviders()}
- />,
- context
- );
- expect(wrapper.find('PanelAlert[type="warning"]').exists()).toBe(false);
- });
- it('does not render with sso and require 2fa disabled', function() {
- const context = TestStubs.routerContext([
- {organization: TestStubs.Organization({...withSSO})},
- ]);
- const wrapper = shallow(
- <OrganizationAuthList
- orgId="org-slug"
- onSendReminders={() => {}}
- providerList={TestStubs.AuthProviders()}
- />,
- context
- );
- expect(wrapper.find('PanelAlert[type="warning"]').exists()).toBe(false);
- });
- it('does not render with saml and require 2fa disabled', function() {
- const context = TestStubs.routerContext([
- {organization: TestStubs.Organization({...withSAML})},
- ]);
- const wrapper = shallow(
- <OrganizationAuthList
- orgId="org-slug"
- onSendReminders={() => {}}
- providerList={TestStubs.AuthProviders()}
- />,
- context
- );
- expect(wrapper.find('PanelAlert[type="warning"]').exists()).toBe(false);
- });
- });
- });
|