diff options
Diffstat (limited to 'spec/frontend/diffs/components/commit_item_spec.js')
-rw-r--r-- | spec/frontend/diffs/components/commit_item_spec.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/frontend/diffs/components/commit_item_spec.js b/spec/frontend/diffs/components/commit_item_spec.js index 4b4b6351d3f..3c092296130 100644 --- a/spec/frontend/diffs/components/commit_item_spec.js +++ b/spec/frontend/diffs/components/commit_item_spec.js @@ -1,4 +1,5 @@ import { mount } from '@vue/test-utils'; +import { GlFormCheckbox } from '@gitlab/ui'; import getDiffWithCommit from 'test_fixtures/merge_request_diffs/with_commit.json'; import { TEST_HOST } from 'helpers/test_constants'; import { trimText } from 'helpers/text_helper'; @@ -28,6 +29,7 @@ describe('diffs/components/commit_item', () => { const getCommitterElement = () => wrapper.find('.committer'); const getCommitActionsElement = () => wrapper.find('.commit-actions'); const getCommitPipelineStatus = () => wrapper.findComponent(CommitPipelineStatus); + const getCommitCheckbox = () => wrapper.findComponent(GlFormCheckbox); const mountComponent = (propsData) => { wrapper = mount(Component, { @@ -168,4 +170,24 @@ describe('diffs/components/commit_item', () => { expect(getCommitPipelineStatus().exists()).toBe(true); }); }); + + describe('when commit is selectable', () => { + beforeEach(() => { + mountComponent({ + commit: { ...commit }, + isSelectable: true, + }); + }); + + it('renders checkbox', () => { + expect(getCommitCheckbox().exists()).toBe(true); + }); + + it('emits "handleCheckboxChange" event on change', () => { + expect(wrapper.emitted('handleCheckboxChange')).toBeUndefined(); + getCommitCheckbox().vm.$emit('change'); + + expect(wrapper.emitted('handleCheckboxChange')[0]).toEqual([true]); + }); + }); }); |