diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-05 21:08:19 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-05 21:08:19 +0300 |
commit | a8de96bff51846e160b76506dc0ca0fe6f767f64 (patch) | |
tree | 1036f1ca75aba492eaaa3439c84a3109b4684896 /spec/frontend/blob/components/blob_edit_header_spec.js | |
parent | afe2b984524ae4b0c8a0636db7ec5b2c452f0734 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/blob/components/blob_edit_header_spec.js')
-rw-r--r-- | spec/frontend/blob/components/blob_edit_header_spec.js | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/frontend/blob/components/blob_edit_header_spec.js b/spec/frontend/blob/components/blob_edit_header_spec.js new file mode 100644 index 00000000000..db7d7d7d48d --- /dev/null +++ b/spec/frontend/blob/components/blob_edit_header_spec.js @@ -0,0 +1,50 @@ +import { shallowMount } from '@vue/test-utils'; +import BlobEditHeader from '~/blob/components/blob_edit_header.vue'; +import { GlFormInput } from '@gitlab/ui'; + +describe('Blob Header Editing', () => { + let wrapper; + const value = 'foo.md'; + + function createComponent() { + wrapper = shallowMount(BlobEditHeader, { + propsData: { + value, + }, + }); + } + + beforeEach(() => { + createComponent(); + }); + + afterEach(() => { + wrapper.destroy(); + }); + + describe('rendering', () => { + it('matches the snapshot', () => { + expect(wrapper.element).toMatchSnapshot(); + }); + + it('contains a form input field', () => { + expect(wrapper.contains(GlFormInput)).toBe(true); + }); + }); + + describe('functionality', () => { + it('emits input event when the blob name is changed', () => { + const inputComponent = wrapper.find(GlFormInput); + const newValue = 'bar.txt'; + + wrapper.setData({ + name: newValue, + }); + inputComponent.vm.$emit('change'); + + return wrapper.vm.$nextTick().then(() => { + expect(wrapper.emitted().input[0]).toEqual([newValue]); + }); + }); + }); +}); |