diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-04 00:09:37 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-04-04 00:09:37 +0000 |
commit | e3bdfa1a13d7e6c92716324c78b5b20c07eeb7c6 (patch) | |
tree | e8776263096b027d32d4be5118cccc87b00de2bc /spec/frontend/lib/utils | |
parent | c1a50b8195f4e36fda9b233acbde57a449bcf6c3 (diff) | |
download | gitlab-ce-e3bdfa1a13d7e6c92716324c78b5b20c07eeb7c6.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib/utils')
-rw-r--r-- | spec/frontend/lib/utils/url_utility_spec.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/url_utility_spec.js b/spec/frontend/lib/utils/url_utility_spec.js index d0abf2c03a9..4960895890f 100644 --- a/spec/frontend/lib/utils/url_utility_spec.js +++ b/spec/frontend/lib/utils/url_utility_spec.js @@ -485,4 +485,30 @@ describe('URL utility', () => { ); }); }); + + describe('getHTTPProtocol', () => { + const httpProtocol = 'http:'; + const httpsProtocol = 'https:'; + + it.each([[httpProtocol], [httpsProtocol]])( + 'when no url passed, returns correct protocol for %i from window location', + protocol => { + setWindowLocation({ + protocol, + }); + expect(urlUtils.getHTTPProtocol()).toBe(protocol.slice(0, -1)); + }, + ); + + it.each` + url | expectation + ${'not-a-url'} | ${undefined} + ${'wss://example.com'} | ${'wss'} + ${'https://foo.bar'} | ${'https'} + ${'http://foo.bar'} | ${'http'} + ${'http://foo.bar:8080'} | ${'http'} + `('returns correct protocol for $url', ({ url, expectation }) => { + expect(urlUtils.getHTTPProtocol(url)).toBe(expectation); + }); + }); }); |