diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 03:07:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 03:07:51 +0300 |
commit | 4e375367b78bb44bd00957522cd9fc3e6d403fef (patch) | |
tree | 059b1ce541e4128bf03683407d7b5bbbc2094ed5 /spec/frontend/ide/components/branches/item_spec.js | |
parent | 99ddca0d88f1e4e49d61b1aa9d41b5785528d1dc (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/ide/components/branches/item_spec.js')
-rw-r--r-- | spec/frontend/ide/components/branches/item_spec.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/frontend/ide/components/branches/item_spec.js b/spec/frontend/ide/components/branches/item_spec.js new file mode 100644 index 00000000000..1db3750609b --- /dev/null +++ b/spec/frontend/ide/components/branches/item_spec.js @@ -0,0 +1,56 @@ +import Vue from 'vue'; +import mountCompontent from 'helpers/vue_mount_component_helper'; +import router from '~/ide/ide_router'; +import Item from '~/ide/components/branches/item.vue'; +import { getTimeago } from '~/lib/utils/datetime_utility'; +import { projectData } from '../../mock_data'; + +const TEST_BRANCH = { + name: 'master', + committedDate: '2018-01-05T05:50Z', +}; +const TEST_PROJECT_ID = projectData.name_with_namespace; + +describe('IDE branch item', () => { + const Component = Vue.extend(Item); + let vm; + + beforeEach(() => { + vm = mountCompontent(Component, { + item: { ...TEST_BRANCH }, + projectId: TEST_PROJECT_ID, + isActive: false, + }); + }); + + afterEach(() => { + vm.$destroy(); + }); + + it('renders branch name and timeago', () => { + const timeText = getTimeago().format(TEST_BRANCH.committedDate); + + expect(vm.$el.textContent).toContain(TEST_BRANCH.name); + expect(vm.$el.querySelector('time')).toHaveText(timeText); + expect(vm.$el.querySelector('.ic-mobile-issue-close')).toBe(null); + }); + + it('renders link to branch', () => { + const expectedHref = router.resolve(`/project/${TEST_PROJECT_ID}/edit/${TEST_BRANCH.name}`) + .href; + + expect(vm.$el.textContent).toMatch('a'); + expect(vm.$el).toHaveAttr('href', expectedHref); + }); + + it('renders icon if isActive', done => { + vm.isActive = true; + + vm.$nextTick() + .then(() => { + expect(vm.$el.querySelector('.ic-mobile-issue-close')).not.toBe(null); + }) + .then(done) + .catch(done.fail); + }); +}); |