diff options
Diffstat (limited to 'spec/frontend/jira_connect/components/app_spec.js')
-rw-r--r-- | spec/frontend/jira_connect/components/app_spec.js | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/spec/frontend/jira_connect/components/app_spec.js b/spec/frontend/jira_connect/components/app_spec.js index be990d5061c..d11b66b2089 100644 --- a/spec/frontend/jira_connect/components/app_spec.js +++ b/spec/frontend/jira_connect/components/app_spec.js @@ -1,19 +1,20 @@ -import Vue from 'vue'; -import Vuex from 'vuex'; +import { GlAlert, GlButton, GlModal } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; -import { GlAlert } from '@gitlab/ui'; + import JiraConnectApp from '~/jira_connect/components/app.vue'; import createStore from '~/jira_connect/store'; import { SET_ERROR_MESSAGE } from '~/jira_connect/store/mutation_types'; -Vue.use(Vuex); +jest.mock('~/jira_connect/api'); describe('JiraConnectApp', () => { let wrapper; let store; const findAlert = () => wrapper.findComponent(GlAlert); + const findGlButton = () => wrapper.findComponent(GlButton); + const findGlModal = () => wrapper.findComponent(GlModal); const findHeader = () => wrapper.findByTestId('new-jira-connect-ui-heading'); const findHeaderText = () => findHeader().text(); @@ -44,6 +45,33 @@ describe('JiraConnectApp', () => { expect(findHeaderText()).toBe('Linked namespaces'); }); + describe('when user is not logged in', () => { + beforeEach(() => { + createComponent({ + provide: { + glFeatures: { newJiraConnectUi: true }, + usersPath: '/users', + }, + }); + }); + + it('renders "Sign in" button', () => { + expect(findGlButton().text()).toBe('Sign in to add namespaces'); + expect(findGlModal().exists()).toBe(false); + }); + }); + + describe('when user is logged in', () => { + beforeEach(() => { + createComponent(); + }); + + it('renders "Add" button and modal', () => { + expect(findGlButton().text()).toBe('Add namespace'); + expect(findGlModal().exists()).toBe(true); + }); + }); + describe('newJiraConnectUi is false', () => { it('does not render new UI', () => { createComponent({ |