diff options
Diffstat (limited to 'spec/frontend/pipeline_editor/components/commit/commit_form_spec.js')
-rw-r--r-- | spec/frontend/pipeline_editor/components/commit/commit_form_spec.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/frontend/pipeline_editor/components/commit/commit_form_spec.js b/spec/frontend/pipeline_editor/components/commit/commit_form_spec.js index 8040c9d701c..23219042008 100644 --- a/spec/frontend/pipeline_editor/components/commit/commit_form_spec.js +++ b/spec/frontend/pipeline_editor/components/commit/commit_form_spec.js @@ -5,6 +5,9 @@ import CommitForm from '~/pipeline_editor/components/commit/commit_form.vue'; import { mockCommitMessage, mockDefaultBranch } from '../../mock_data'; +const scrollIntoViewMock = jest.fn(); +HTMLElement.prototype.scrollIntoView = scrollIntoViewMock; + describe('Pipeline Editor | Commit Form', () => { let wrapper; @@ -113,4 +116,20 @@ describe('Pipeline Editor | Commit Form', () => { expect(findSubmitBtn().attributes('disabled')).toBe('disabled'); }); }); + + describe('when scrollToCommitForm becomes true', () => { + beforeEach(async () => { + createComponent(); + wrapper.setProps({ scrollToCommitForm: true }); + await wrapper.vm.$nextTick(); + }); + + it('scrolls into view', () => { + expect(scrollIntoViewMock).toHaveBeenCalledWith({ behavior: 'smooth' }); + }); + + it('emits "scrolled-to-commit-form"', () => { + expect(wrapper.emitted()['scrolled-to-commit-form']).toBeTruthy(); + }); + }); }); |