diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-04 15:10:04 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-04 15:10:04 +0300 |
commit | 998adcc422d4161515bf2960ef4dce71258f69a3 (patch) | |
tree | 34ffbf53b8587d3367457d4175fc8dfd71477dca /spec/frontend/issuable | |
parent | e2c471038ab2b4f09487c1feb74520f74f834986 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/issuable')
-rw-r--r-- | spec/frontend/issuable/components/status_box_spec.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/spec/frontend/issuable/components/status_box_spec.js b/spec/frontend/issuable/components/status_box_spec.js new file mode 100644 index 00000000000..990fac67f7e --- /dev/null +++ b/spec/frontend/issuable/components/status_box_spec.js @@ -0,0 +1,71 @@ +import { GlSprintf } from '@gitlab/ui'; +import { shallowMount } from '@vue/test-utils'; +import StatusBox from '~/issuable/components/status_box.vue'; + +let wrapper; + +function factory(propsData) { + wrapper = shallowMount(StatusBox, { propsData, stubs: { GlSprintf } }); +} + +const testCases = [ + { + name: 'Open', + state: 'opened', + class: 'status-box-open', + icon: 'issue-open-m', + }, + { + name: 'Open', + state: 'locked', + class: 'status-box-open', + icon: 'issue-open-m', + }, + { + name: 'Closed', + state: 'closed', + class: 'status-box-mr-closed', + icon: 'issue-close', + }, + { + name: 'Merged', + state: 'merged', + class: 'status-box-mr-merged', + icon: 'git-merge', + }, +]; + +describe('Merge request status box component', () => { + afterEach(() => { + wrapper.destroy(); + wrapper = null; + }); + + testCases.forEach((testCase) => { + describe(`when merge request is ${testCase.name}`, () => { + it('renders human readable test', () => { + factory({ + initialState: testCase.state, + }); + + expect(wrapper.text()).toContain(testCase.name); + }); + + it('sets css class', () => { + factory({ + initialState: testCase.state, + }); + + expect(wrapper.classes()).toContain(testCase.class); + }); + + it('renders icon', () => { + factory({ + initialState: testCase.state, + }); + + expect(wrapper.find('[data-testid="status-icon"]').props('name')).toBe(testCase.icon); + }); + }); + }); +}); |