diff options
Diffstat (limited to 'spec/frontend/jira_connect/subscriptions/pages')
-rw-r--r-- | spec/frontend/jira_connect/subscriptions/pages/sign_in_spec.js | 62 | ||||
-rw-r--r-- | spec/frontend/jira_connect/subscriptions/pages/subscriptions_spec.js | 56 |
2 files changed, 118 insertions, 0 deletions
diff --git a/spec/frontend/jira_connect/subscriptions/pages/sign_in_spec.js b/spec/frontend/jira_connect/subscriptions/pages/sign_in_spec.js new file mode 100644 index 00000000000..4e3297506f1 --- /dev/null +++ b/spec/frontend/jira_connect/subscriptions/pages/sign_in_spec.js @@ -0,0 +1,62 @@ +import { mount } from '@vue/test-utils'; + +import SignInPage from '~/jira_connect/subscriptions/pages/sign_in.vue'; +import SignInButton from '~/jira_connect/subscriptions/components/sign_in_button.vue'; +import SubscriptionsList from '~/jira_connect/subscriptions/components/subscriptions_list.vue'; +import createStore from '~/jira_connect/subscriptions/store'; + +jest.mock('~/jira_connect/subscriptions/utils'); + +describe('SignInPage', () => { + let wrapper; + let store; + + const findSignInButton = () => wrapper.findComponent(SignInButton); + const findSubscriptionsList = () => wrapper.findComponent(SubscriptionsList); + + const createComponent = ({ provide, props } = {}) => { + store = createStore(); + + wrapper = mount(SignInPage, { + store, + provide, + propsData: props, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + describe('template', () => { + const mockUsersPath = '/test'; + describe.each` + scenario | expectSubscriptionsList | signInButtonText + ${'with subscriptions'} | ${true} | ${SignInPage.i18n.signinButtonTextWithSubscriptions} + ${'without subscriptions'} | ${false} | ${SignInButton.i18n.defaultButtonText} + `('$scenario', ({ expectSubscriptionsList, signInButtonText }) => { + beforeEach(() => { + createComponent({ + provide: { + usersPath: mockUsersPath, + }, + props: { + hasSubscriptions: expectSubscriptionsList, + }, + }); + }); + + it(`renders sign in button with text ${signInButtonText}`, () => { + expect(findSignInButton().text()).toMatchInterpolatedText(signInButtonText); + }); + + it('renders sign in button with `usersPath` prop', () => { + expect(findSignInButton().props('usersPath')).toBe(mockUsersPath); + }); + + it(`${expectSubscriptionsList ? 'renders' : 'does not render'} subscriptions list`, () => { + expect(findSubscriptionsList().exists()).toBe(expectSubscriptionsList); + }); + }); + }); +}); diff --git a/spec/frontend/jira_connect/subscriptions/pages/subscriptions_spec.js b/spec/frontend/jira_connect/subscriptions/pages/subscriptions_spec.js new file mode 100644 index 00000000000..198278efc1f --- /dev/null +++ b/spec/frontend/jira_connect/subscriptions/pages/subscriptions_spec.js @@ -0,0 +1,56 @@ +import { GlEmptyState } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import SubscriptionsPage from '~/jira_connect/subscriptions/pages/subscriptions.vue'; +import AddNamespaceButton from '~/jira_connect/subscriptions/components/add_namespace_button.vue'; +import SubscriptionsList from '~/jira_connect/subscriptions/components/subscriptions_list.vue'; +import createStore from '~/jira_connect/subscriptions/store'; + +describe('SubscriptionsPage', () => { + let wrapper; + let store; + + const findAddNamespaceButton = () => wrapper.findComponent(AddNamespaceButton); + const findSubscriptionsList = () => wrapper.findComponent(SubscriptionsList); + const findEmptyState = () => wrapper.findComponent(GlEmptyState); + + const createComponent = ({ props } = {}) => { + store = createStore(); + + wrapper = shallowMount(SubscriptionsPage, { + store, + propsData: props, + }); + }; + + afterEach(() => { + wrapper.destroy(); + }); + + describe('template', () => { + describe.each` + scenario | expectSubscriptionsList | expectEmptyState + ${'with subscriptions'} | ${true} | ${false} + ${'without subscriptions'} | ${false} | ${true} + `('$scenario', ({ expectEmptyState, expectSubscriptionsList }) => { + beforeEach(() => { + createComponent({ + props: { + hasSubscriptions: expectSubscriptionsList, + }, + }); + }); + + it('renders button to add namespace', () => { + expect(findAddNamespaceButton().exists()).toBe(true); + }); + + it(`${expectEmptyState ? 'renders' : 'does not render'} empty state`, () => { + expect(findEmptyState().exists()).toBe(expectEmptyState); + }); + + it(`${expectSubscriptionsList ? 'renders' : 'does not render'} subscriptions list`, () => { + expect(findSubscriptionsList().exists()).toBe(expectSubscriptionsList); + }); + }); + }); +}); |