diff options
Diffstat (limited to 'spec/frontend')
-rw-r--r-- | spec/frontend/registry/explorer/utils_spec.js | 17 | ||||
-rw-r--r-- | spec/frontend/vue_mr_widget/mr_widget_options_spec.js | 14 |
2 files changed, 28 insertions, 3 deletions
diff --git a/spec/frontend/registry/explorer/utils_spec.js b/spec/frontend/registry/explorer/utils_spec.js index 0cd4a1cec29..7a5d6958a09 100644 --- a/spec/frontend/registry/explorer/utils_spec.js +++ b/spec/frontend/registry/explorer/utils_spec.js @@ -8,6 +8,10 @@ describe('Utils', () => { id: 1, }; + beforeEach(() => { + window.gon.relative_url_root = null; + }); + it('returns the fetch url when no ending is passed', () => { expect(pathGenerator(imageDetails)).toBe('/foo/bar/registry/repository/1/tags?format=json'); }); @@ -16,7 +20,7 @@ describe('Utils', () => { expect(pathGenerator(imageDetails, '/foo')).toBe('/foo/bar/registry/repository/1/tags/foo'); }); - it.each` + describe.each` path | name | result ${'foo/foo'} | ${''} | ${'/foo/foo/registry/repository/1/tags?format=json'} ${'foo/foo/foo'} | ${'foo'} | ${'/foo/foo/registry/repository/1/tags?format=json'} @@ -26,8 +30,15 @@ describe('Utils', () => { ${'foo/foo/baz/foo/bar'} | ${'foo/bar'} | ${'/foo/foo/baz/registry/repository/1/tags?format=json'} ${'baz/foo/foo'} | ${'foo'} | ${'/baz/foo/registry/repository/1/tags?format=json'} ${'baz/foo/bar'} | ${'foo'} | ${'/baz/foo/bar/registry/repository/1/tags?format=json'} - `('returns the correct path when path is $path and name is $name', ({ name, path, result }) => { - expect(pathGenerator({ id: 1, name, path })).toBe(result); + `('when path is $path and name is $name', ({ name, path, result }) => { + it('returns the correct value', () => { + expect(pathGenerator({ id: 1, name, path })).toBe(result); + }); + + it('produces a correct relative url', () => { + window.gon.relative_url_root = '/gitlab'; + expect(pathGenerator({ id: 1, name, path })).toBe(`/gitlab${result}`); + }); }); it('returns the url unchanged when imageDetails have no name', () => { diff --git a/spec/frontend/vue_mr_widget/mr_widget_options_spec.js b/spec/frontend/vue_mr_widget/mr_widget_options_spec.js index d6f85dcfcc7..cb0006548d4 100644 --- a/spec/frontend/vue_mr_widget/mr_widget_options_spec.js +++ b/spec/frontend/vue_mr_widget/mr_widget_options_spec.js @@ -260,6 +260,20 @@ describe('mrWidgetOptions', () => { }); }); }); + + describe('formattedHumanAccess', () => { + it('when user is a tool admin but not a member of project', () => { + vm.mr.humanAccess = null; + + expect(vm.formattedHumanAccess).toEqual(''); + }); + + it('when user a member of the project', () => { + vm.mr.humanAccess = 'Owner'; + + expect(vm.formattedHumanAccess).toEqual('owner'); + }); + }); }); describe('methods', () => { |