diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-30 21:10:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-30 21:10:09 +0000 |
commit | 15229b03e058208b2feac568832eb43f109ac3cd (patch) | |
tree | 2bb2063ae02a72849091c9588945d03df7710ad5 /spec/frontend/lib/utils/url_utility_spec.js | |
parent | 6010cf135a52a37b200112fa353900a690f958a7 (diff) | |
download | gitlab-ce-15229b03e058208b2feac568832eb43f109ac3cd.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib/utils/url_utility_spec.js')
-rw-r--r-- | spec/frontend/lib/utils/url_utility_spec.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/url_utility_spec.js b/spec/frontend/lib/utils/url_utility_spec.js index e92a9a69b5b..3cc675d2007 100644 --- a/spec/frontend/lib/utils/url_utility_spec.js +++ b/spec/frontend/lib/utils/url_utility_spec.js @@ -814,4 +814,22 @@ describe('URL utility', () => { expect(urlUtils.stripPathTail(path)).toBe(expected); }); }); + + describe('getURLOrigin', () => { + it('when no url passed, returns correct origin from window location', () => { + const origin = 'https://foo.bar'; + + setWindowLocation({ origin }); + expect(urlUtils.getURLOrigin()).toBe(origin); + }); + + it.each` + url | expectation + ${'not-a-url'} | ${null} + ${'wss://example.com'} | ${'wss://example.com'} + ${'https://foo.bar/foo/bar'} | ${'https://foo.bar'} + `('returns correct origin for $url', ({ url, expectation }) => { + expect(urlUtils.getURLOrigin(url)).toBe(expectation); + }); + }); }); |