Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
gitpod-io
GitHub Repository: gitpod-io/gitpod
Path: blob/main/components/gitpod-protocol/src/context-url.spec.ts
2498 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 { Workspace } from ".";
10
import { ContextURL } from "./context-url";
11
const expect = chai.expect;
12
13
type WsContextUrl = Pick<Workspace, "context" | "contextURL">;
14
15
@suite
16
export class ContextUrlTest {
17
@test public parseContextUrl_withEnvVar() {
18
const actual = ContextURL.getNormalizedURL({
19
contextURL: "passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo",
20
context: {},
21
} as WsContextUrl);
22
expect(actual?.host).to.equal("github.com");
23
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
24
}
25
26
@test public parseContextUrl_withEnvVar_withoutSchema() {
27
const actual = ContextURL.getNormalizedURL({
28
contextURL: "passedin=test%20value/github.com/gitpod-io/gitpod-test-repo",
29
context: {},
30
} as WsContextUrl);
31
expect(actual?.host).to.equal("github.com");
32
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
33
}
34
35
@test public parseContextUrl_withEnvVar_sshUrl() {
36
const actual = ContextURL.getNormalizedURL({
37
contextURL: "passedin=test%20value/[email protected]:gitpod-io/gitpod-test-repo.git",
38
context: {},
39
} as WsContextUrl);
40
expect(actual?.host).to.equal("github.com");
41
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo.git");
42
}
43
44
@test public parseContextUrl_badUrl() {
45
const actual = ContextURL.getNormalizedURL({ contextURL: "[Object object]", context: {} } as WsContextUrl);
46
expect(actual).to.be.undefined;
47
}
48
}
49
module.exports = new ContextUrlTest();
50
51