diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-03 15:18:57 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-03 15:18:57 +0300 |
commit | 584ccdaf68710dec2c717a010cbab2610c0155ed (patch) | |
tree | 188e1f5609f5990ae3c3904d3752cf9603157596 /spec/frontend/vue_shared/components/design_management | |
parent | ffe7c069a4e16f77b80c7159690a4c8060dd74d9 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/vue_shared/components/design_management')
-rw-r--r-- | spec/frontend/vue_shared/components/design_management/design_note_pin_spec.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/spec/frontend/vue_shared/components/design_management/design_note_pin_spec.js b/spec/frontend/vue_shared/components/design_management/design_note_pin_spec.js index 984a28c93d6..353d493add9 100644 --- a/spec/frontend/vue_shared/components/design_management/design_note_pin_spec.js +++ b/spec/frontend/vue_shared/components/design_management/design_note_pin_spec.js @@ -39,4 +39,72 @@ describe('Design note pin component', () => { createComponent({ position: null }); expect(wrapper.element).toMatchSnapshot(); }); + + it('applies `on-image` class when isOnImage is true', () => { + createComponent({ isOnImage: true }); + + expect(wrapper.find('.on-image').exists()).toBe(true); + }); + + it('applies `draft` class when isDraft is true', () => { + createComponent({ isDraft: true }); + + expect(wrapper.find('.draft').exists()).toBe(true); + }); + + describe('size', () => { + it('is `sm` it applies `small` class', () => { + createComponent({ size: 'sm' }); + expect(wrapper.find('.small').exists()).toBe(true); + }); + + it('is `md` it applies no size class', () => { + createComponent({ size: 'md' }); + expect(wrapper.find('.small').exists()).toBe(false); + expect(wrapper.find('.medium').exists()).toBe(false); + }); + + it('throws when passed any other value except `sm` or `md`', () => { + jest.spyOn(console, 'error').mockImplementation(() => {}); + + createComponent({ size: 'lg' }); + + // eslint-disable-next-line no-console + expect(console.error).toHaveBeenCalled(); + }); + }); + + describe('ariaLabel', () => { + describe('when value is passed', () => { + it('overrides default aria-label', () => { + const ariaLabel = 'Aria Label'; + + createComponent({ ariaLabel }); + + const button = wrapper.find('button'); + + expect(button.attributes('aria-label')).toBe(ariaLabel); + }); + }); + + describe('when no value is passed', () => { + it('shows new note label as aria-label when label is absent', () => { + createComponent({ label: null }); + + const button = wrapper.find('button'); + + expect(button.attributes('aria-label')).toBe('Comment form position'); + }); + + it('shows label position as aria-label when label is present', () => { + const label = 1; + + createComponent({ label, isNewNote: false }); + + const button = wrapper.find('button'); + + expect(button.attributes('aria-label')).toBe(`Comment '${label}' position`); + }); + }); + }); }); |