Path: blob/main/components/gitpod-protocol/src/context-url.spec.ts
2498 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 { Workspace } from ".";9import { ContextURL } from "./context-url";10const expect = chai.expect;1112type WsContextUrl = Pick<Workspace, "context" | "contextURL">;1314@suite15export class ContextUrlTest {16@test public parseContextUrl_withEnvVar() {17const actual = ContextURL.getNormalizedURL({18contextURL: "passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo",19context: {},20} as WsContextUrl);21expect(actual?.host).to.equal("github.com");22expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");23}2425@test public parseContextUrl_withEnvVar_withoutSchema() {26const actual = ContextURL.getNormalizedURL({27contextURL: "passedin=test%20value/github.com/gitpod-io/gitpod-test-repo",28context: {},29} as WsContextUrl);30expect(actual?.host).to.equal("github.com");31expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");32}3334@test public parseContextUrl_withEnvVar_sshUrl() {35const actual = ContextURL.getNormalizedURL({36contextURL: "passedin=test%20value/[email protected]:gitpod-io/gitpod-test-repo.git",37context: {},38} as WsContextUrl);39expect(actual?.host).to.equal("github.com");40expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo.git");41}4243@test public parseContextUrl_badUrl() {44const actual = ContextURL.getNormalizedURL({ contextURL: "[Object object]", context: {} } as WsContextUrl);45expect(actual).to.be.undefined;46}47}48module.exports = new ContextUrlTest();495051