diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-02 18:13:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-03-02 18:13:35 +0300 |
commit | b2c21b99c7eb52b5fd906b1e7b4b08d4eb7a296c (patch) | |
tree | cef64d6aa4d2d7e008bcdb84c754eab8e9ee117c /spec/frontend | |
parent | ce459835cb32ed396fb7524fb615a5d07f8c51ef (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/lib/utils/text_utility_spec.js | 32 | ||||
-rw-r--r-- | spec/frontend/vue_shared/components/tooltip_on_truncate_spec.js | 18 |
2 files changed, 42 insertions, 8 deletions
diff --git a/spec/frontend/lib/utils/text_utility_spec.js b/spec/frontend/lib/utils/text_utility_spec.js index f2572ca0ad2..71a84d56791 100644 --- a/spec/frontend/lib/utils/text_utility_spec.js +++ b/spec/frontend/lib/utils/text_utility_spec.js @@ -398,4 +398,36 @@ describe('text_utility', () => { expect(textUtils.base64DecodeUnicode('8J+YgA==')).toBe('😀'); }); }); + + describe('findInvalidBranchNameCharacters', () => { + const invalidChars = [' ', '~', '^', ':', '?', '*', '[', '..', '@{', '\\', '//']; + const badBranchName = 'branch-with all these ~ ^ : ? * [ ] \\ // .. @{ } //'; + const goodBranch = 'branch-with-no-errrors'; + + it('returns an array of invalid characters in a branch name', () => { + const chars = textUtils.findInvalidBranchNameCharacters(badBranchName); + chars.forEach((char) => { + expect(invalidChars).toContain(char); + }); + }); + + it('returns an empty array with no invalid characters', () => { + expect(textUtils.findInvalidBranchNameCharacters(goodBranch)).toEqual([]); + }); + }); + + describe('humanizeBranchValidationErrors', () => { + it.each` + errors | message + ${[' ']} | ${"Can't contain spaces"} + ${['?', '//', ' ']} | ${"Can't contain spaces, ?, //"} + ${['\\', '[', '..']} | ${"Can't contain \\, [, .."} + `('returns an $message with $errors', ({ errors, message }) => { + expect(textUtils.humanizeBranchValidationErrors(errors)).toEqual(message); + }); + + it('returns an empty string with no invalid characters', () => { + expect(textUtils.humanizeBranchValidationErrors([])).toEqual(''); + }); + }); }); diff --git a/spec/frontend/vue_shared/components/tooltip_on_truncate_spec.js b/spec/frontend/vue_shared/components/tooltip_on_truncate_spec.js index 5e7b2a89235..01fc2dc4661 100644 --- a/spec/frontend/vue_shared/components/tooltip_on_truncate_spec.js +++ b/spec/frontend/vue_shared/components/tooltip_on_truncate_spec.js @@ -90,7 +90,7 @@ describe('TooltipOnTruncate component', () => { it('renders tooltip', async () => { expect(hasHorizontalOverflow).toHaveBeenLastCalledWith(wrapper.element); - expect(getTooltipValue()).toMatchObject({ + expect(getTooltipValue()).toStrictEqual({ title: MOCK_TITLE, placement: 'top', disabled: false, @@ -144,7 +144,7 @@ describe('TooltipOnTruncate component', () => { await nextTick(); - expect(getTooltipValue()).toMatchObject({ + expect(getTooltipValue()).toStrictEqual({ title: MOCK_TITLE, placement: 'top', disabled: false, @@ -194,20 +194,22 @@ describe('TooltipOnTruncate component', () => { }); }); - describe('placement', () => { - it('sets placement when tooltip is rendered', () => { - const mockPlacement = 'bottom'; - + describe('tooltip customization', () => { + it.each` + property | mockValue + ${'placement'} | ${'bottom'} + ${'boundary'} | ${'viewport'} + `('sets $property when the tooltip is rendered', ({ property, mockValue }) => { hasHorizontalOverflow.mockReturnValueOnce(true); createComponent({ propsData: { - placement: mockPlacement, + [property]: mockValue, }, }); expect(hasHorizontalOverflow).toHaveBeenLastCalledWith(wrapper.element); expect(getTooltipValue()).toMatchObject({ - placement: mockPlacement, + [property]: mockValue, }); }); }); |