diff options
Diffstat (limited to 'spec/javascripts/ide/components/nav_dropdown_button_spec.js')
-rw-r--r-- | spec/javascripts/ide/components/nav_dropdown_button_spec.js | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/spec/javascripts/ide/components/nav_dropdown_button_spec.js b/spec/javascripts/ide/components/nav_dropdown_button_spec.js deleted file mode 100644 index bbaf97164ea..00000000000 --- a/spec/javascripts/ide/components/nav_dropdown_button_spec.js +++ /dev/null @@ -1,93 +0,0 @@ -import Vue from 'vue'; -import { trimText } from 'spec/helpers/text_helper'; -import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; -import NavDropdownButton from '~/ide/components/nav_dropdown_button.vue'; -import { createStore } from '~/ide/stores'; - -describe('NavDropdown', () => { - const TEST_BRANCH_ID = 'lorem-ipsum-dolar'; - const TEST_MR_ID = '12345'; - let store; - let vm; - - beforeEach(() => { - store = createStore(); - }); - - afterEach(() => { - vm.$destroy(); - }); - - const createComponent = (props = {}) => { - vm = mountComponentWithStore(Vue.extend(NavDropdownButton), { props, store }); - vm.$mount(); - }; - - const findIcon = name => vm.$el.querySelector(`.ic-${name}`); - const findMRIcon = () => findIcon('merge-request'); - const findBranchIcon = () => findIcon('branch'); - - describe('normal', () => { - beforeEach(() => { - createComponent(); - }); - - it('renders empty placeholders, if state is falsey', () => { - expect(trimText(vm.$el.textContent)).toEqual('- -'); - }); - - it('renders branch name, if state has currentBranchId', done => { - vm.$store.state.currentBranchId = TEST_BRANCH_ID; - - vm.$nextTick() - .then(() => { - expect(trimText(vm.$el.textContent)).toEqual(`${TEST_BRANCH_ID} -`); - }) - .then(done) - .catch(done.fail); - }); - - it('renders mr id, if state has currentMergeRequestId', done => { - vm.$store.state.currentMergeRequestId = TEST_MR_ID; - - vm.$nextTick() - .then(() => { - expect(trimText(vm.$el.textContent)).toEqual(`- !${TEST_MR_ID}`); - }) - .then(done) - .catch(done.fail); - }); - - it('renders branch and mr, if state has both', done => { - vm.$store.state.currentBranchId = TEST_BRANCH_ID; - vm.$store.state.currentMergeRequestId = TEST_MR_ID; - - vm.$nextTick() - .then(() => { - expect(trimText(vm.$el.textContent)).toEqual(`${TEST_BRANCH_ID} !${TEST_MR_ID}`); - }) - .then(done) - .catch(done.fail); - }); - - it('shows icons', () => { - expect(findBranchIcon()).toBeTruthy(); - expect(findMRIcon()).toBeTruthy(); - }); - }); - - describe('with showMergeRequests false', () => { - beforeEach(() => { - createComponent({ showMergeRequests: false }); - }); - - it('shows single empty placeholder, if state is falsey', () => { - expect(trimText(vm.$el.textContent)).toEqual('-'); - }); - - it('shows only branch icon', () => { - expect(findBranchIcon()).toBeTruthy(); - expect(findMRIcon()).toBe(null); - }); - }); -}); |