mirror of
https://github.com/gitpod-io/gitpod.git
synced 2025-12-08 17:36:30 +00:00
* [ts] Pin mimimatch and minimist * [server] Update minio * [ts] Remove superfluous node-pre-gyp dep * [ts] Pin jsonwebtoken to 9.0.0 * [grpc] Update grpc-toolsis * [ts] Upgrade from mocha-typescript to @testdeck/mocha * fix rimraf
50 lines
1.8 KiB
TypeScript
50 lines
1.8 KiB
TypeScript
/**
|
|
* Copyright (c) 2020 Gitpod GmbH. All rights reserved.
|
|
* Licensed under the GNU Affero General Public License (AGPL).
|
|
* See License.AGPL.txt in the project root for license information.
|
|
*/
|
|
|
|
import * as chai from "chai";
|
|
import { suite, test } from "@testdeck/mocha";
|
|
import { Workspace } from ".";
|
|
import { ContextURL } from "./context-url";
|
|
const expect = chai.expect;
|
|
|
|
type WsContextUrl = Pick<Workspace, "context" | "contextURL">;
|
|
|
|
@suite
|
|
export class ContextUrlTest {
|
|
@test public parseContextUrl_withEnvVar() {
|
|
const actual = ContextURL.getNormalizedURL({
|
|
contextURL: "passedin=test%20value/https://github.com/gitpod-io/gitpod-test-repo",
|
|
context: {},
|
|
} as WsContextUrl);
|
|
expect(actual?.host).to.equal("github.com");
|
|
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
}
|
|
|
|
@test public parseContextUrl_withEnvVar_withoutSchema() {
|
|
const actual = ContextURL.getNormalizedURL({
|
|
contextURL: "passedin=test%20value/github.com/gitpod-io/gitpod-test-repo",
|
|
context: {},
|
|
} as WsContextUrl);
|
|
expect(actual?.host).to.equal("github.com");
|
|
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo");
|
|
}
|
|
|
|
@test public parseContextUrl_withEnvVar_sshUrl() {
|
|
const actual = ContextURL.getNormalizedURL({
|
|
contextURL: "passedin=test%20value/git@github.com:gitpod-io/gitpod-test-repo.git",
|
|
context: {},
|
|
} as WsContextUrl);
|
|
expect(actual?.host).to.equal("github.com");
|
|
expect(actual?.pathname).to.equal("/gitpod-io/gitpod-test-repo.git");
|
|
}
|
|
|
|
@test public parseContextUrl_badUrl() {
|
|
const actual = ContextURL.getNormalizedURL({ contextURL: "[Object object]", context: {} } as WsContextUrl);
|
|
expect(actual).to.be.undefined;
|
|
}
|
|
}
|
|
module.exports = new ContextUrlTest();
|