Path: blob/main/components/gitpod-protocol/src/util/gitpod-host-url.spec.ts
2500 views
/**1* Copyright (c) 2020 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import * as chai from "chai";7import { suite, test } from "@testdeck/mocha";8import { GitpodHostUrl } from "./gitpod-host-url";9const expect = chai.expect;1011@suite12export class GitpodHostUrlTest {13@test public parseWorkspaceId_hosts_withEnvVarsInjected() {14const actual = new GitpodHostUrl(15"https://gray-grasshopper-nfbitfia.ws-eu02.gitpod-staging.com/#passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo",16).workspaceId;17expect(actual).to.equal("gray-grasshopper-nfbitfia");18}1920@test public async testWithoutWorkspacePrefix() {21expect(22new GitpodHostUrl("https://3000-moccasin-ferret-155799b3.ws-eu02.gitpod-staging.com/")23.withoutWorkspacePrefix()24.toString(),25).to.equal("https://gitpod-staging.com/");26}2728@test public async testWithoutWorkspacePrefix2() {29expect(new GitpodHostUrl("https://gitpod-staging.com/").withoutWorkspacePrefix().toString()).to.equal(30"https://gitpod-staging.com/",31);32}3334@test public async testWithoutWorkspacePrefix3() {35expect(36new GitpodHostUrl("https://gray-rook-5523v5d8.ws-dev.my-branch-1234.staging.gitpod-dev.com/")37.withoutWorkspacePrefix()38.toString(),39).to.equal("https://my-branch-1234.staging.gitpod-dev.com/");40}4142@test public async testWithoutWorkspacePrefix4() {43expect(44new GitpodHostUrl("https://my-branch-1234.staging.gitpod-dev.com/").withoutWorkspacePrefix().toString(),45).to.equal("https://my-branch-1234.staging.gitpod-dev.com/");46}4748@test public async testWithoutWorkspacePrefix5() {49expect(50new GitpodHostUrl("https://abc-nice-brunch-4224.staging.gitpod-dev.com/")51.withoutWorkspacePrefix()52.toString(),53).to.equal("https://abc-nice-brunch-4224.staging.gitpod-dev.com/");54}5556@test public async testWithoutWorkspacePrefix6() {57expect(58new GitpodHostUrl("https://gray-rook-5523v5d8.ws-dev.abc-nice-brunch-4224.staging.gitpod-dev.com/")59.withoutWorkspacePrefix()60.toString(),61).to.equal("https://abc-nice-brunch-4224.staging.gitpod-dev.com/");62}63}64module.exports = new GitpodHostUrlTest();656667