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