diff options
Diffstat (limited to 'spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js')
-rw-r--r-- | spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js | 74 |
1 files changed, 21 insertions, 53 deletions
diff --git a/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js b/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js index b9a8451f3b3..4cfd925db34 100644 --- a/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js +++ b/spec/frontend/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com_spec.js @@ -1,7 +1,6 @@ import { shallowMount } from '@vue/test-utils'; import SignInGitlabCom from '~/jira_connect/subscriptions/pages/sign_in/sign_in_gitlab_com.vue'; -import SignInLegacyButton from '~/jira_connect/subscriptions/components/sign_in_legacy_button.vue'; import SignInOauthButton from '~/jira_connect/subscriptions/components/sign_in_oauth_button.vue'; import SubscriptionsList from '~/jira_connect/subscriptions/components/subscriptions_list.vue'; import createStore from '~/jira_connect/subscriptions/store'; @@ -9,100 +8,69 @@ import { I18N_DEFAULT_SIGN_IN_BUTTON_TEXT } from '~/jira_connect/subscriptions/c jest.mock('~/jira_connect/subscriptions/utils'); -const mockUsersPath = '/test'; const defaultProvide = { oauthMetadata: {}, - usersPath: mockUsersPath, }; describe('SignInGitlabCom', () => { let wrapper; let store; - const findSignInLegacyButton = () => wrapper.findComponent(SignInLegacyButton); const findSignInOauthButton = () => wrapper.findComponent(SignInOauthButton); const findSubscriptionsList = () => wrapper.findComponent(SubscriptionsList); - const createComponent = ({ props, jiraConnectOauthEnabled } = {}) => { + const createComponent = ({ props } = {}) => { store = createStore(); wrapper = shallowMount(SignInGitlabCom, { store, provide: { ...defaultProvide, - glFeatures: { - jiraConnectOauth: jiraConnectOauthEnabled, - }, }, propsData: props, stubs: { - SignInLegacyButton, SignInOauthButton, }, }); }; - afterEach(() => { - wrapper.destroy(); - }); - describe('template', () => { describe.each` scenario | hasSubscriptions | signInButtonText ${'with subscriptions'} | ${true} | ${SignInGitlabCom.i18n.signInButtonTextWithSubscriptions} ${'without subscriptions'} | ${false} | ${I18N_DEFAULT_SIGN_IN_BUTTON_TEXT} `('$scenario', ({ hasSubscriptions, signInButtonText }) => { - describe('when `jiraConnectOauthEnabled` feature flag is disabled', () => { - beforeEach(() => { - createComponent({ - jiraConnectOauthEnabled: false, - props: { - hasSubscriptions, - }, - }); - }); - - it('renders legacy sign in button', () => { - const button = findSignInLegacyButton(); - expect(button.props('usersPath')).toBe(mockUsersPath); - expect(button.text()).toMatchInterpolatedText(signInButtonText); + beforeEach(() => { + createComponent({ + props: { + hasSubscriptions, + }, }); }); - describe('when `jiraConnectOauthEnabled` feature flag is enabled', () => { - beforeEach(() => { - createComponent({ - jiraConnectOauthEnabled: true, - props: { - hasSubscriptions, - }, - }); + describe('oauth sign in button', () => { + it('renders oauth sign in button', () => { + const button = findSignInOauthButton(); + expect(button.text()).toMatchInterpolatedText(signInButtonText); }); - describe('oauth sign in button', () => { - it('renders oauth sign in button', () => { + describe('when button emits `sign-in` event', () => { + it('emits `sign-in-oauth` event', () => { const button = findSignInOauthButton(); - expect(button.text()).toMatchInterpolatedText(signInButtonText); - }); - - describe('when button emits `sign-in` event', () => { - it('emits `sign-in-oauth` event', () => { - const button = findSignInOauthButton(); - const mockUser = { name: 'test' }; - button.vm.$emit('sign-in', mockUser); + const mockUser = { name: 'test' }; + button.vm.$emit('sign-in', mockUser); - expect(wrapper.emitted('sign-in-oauth')[0]).toEqual([mockUser]); - }); + expect(wrapper.emitted('sign-in-oauth')[0]).toEqual([mockUser]); }); + }); - describe('when button emits `error` event', () => { - it('emits `error` event', () => { - const button = findSignInOauthButton(); - button.vm.$emit('error'); + describe('when button emits `error` event', () => { + it('emits `error` event', () => { + const button = findSignInOauthButton(); + button.vm.$emit('error'); - expect(wrapper.emitted('error')).toHaveLength(1); - }); + expect(wrapper.emitted('error')).toHaveLength(1); }); }); }); |