Update to ADO 5ed9b2130da7f822153531489d802c28986f5d30

This commit is contained in:
Steve Faulkner
2020-05-26 13:53:41 -05:00
parent 36581fb6d9
commit 0494da4162
42 changed files with 1186 additions and 2242 deletions

View File

@@ -1,50 +1,32 @@
import { GitHubUtils } from "./GitHubUtils";
const owner = "owner-1";
const repo = "repo-1";
const branch = "branch/name.1-2";
const path = "folder name/file name1:2.ipynb";
describe("GitHubUtils", () => {
describe("fromGitHubUri", () => {
it("parses github repo url for a branch", () => {
const gitHubInfo = GitHubUtils.fromGitHubUri("https://github.com/owner/repo/tree/branch");
expect(gitHubInfo).toEqual({
owner: "owner",
repo: "repo",
branch: "branch",
path: ""
});
});
it("parses github file url", () => {
const gitHubInfo = GitHubUtils.fromGitHubUri("https://github.com/owner/repo/blob/branch/dir/file.ext");
expect(gitHubInfo).toEqual({
owner: "owner",
repo: "repo",
branch: "branch",
path: "dir/file.ext"
});
});
it("parses github file url with spaces", () => {
const gitHubInfo = GitHubUtils.fromGitHubUri("https://github.com/owner/repo/blob/branch/dir/file name.ext");
expect(gitHubInfo).toEqual({
owner: "owner",
repo: "repo",
branch: "branch",
path: "dir/file name.ext"
});
});
it("parses github file url with encoded chars", () => {
const gitHubInfo = GitHubUtils.fromGitHubUri("https://github.com/owner/repo/blob/branch/dir/file%20name.ext");
expect(gitHubInfo).toEqual({
owner: "owner",
repo: "repo",
branch: "branch",
path: "dir/file%20name.ext"
});
it("fromRepoUri parses github repo url correctly", () => {
const repoInfo = GitHubUtils.fromRepoUri(`https://github.com/${owner}/${repo}/tree/${branch}`);
expect(repoInfo).toEqual({
owner,
repo,
branch
});
});
it("toRepoFullName returns full name in expected format", () => {
const fullName = GitHubUtils.toRepoFullName("owner", "repo");
expect(fullName).toBe("owner/repo");
it("toContentUri generates github uris correctly", () => {
const uri = GitHubUtils.toContentUri(owner, repo, branch, path);
expect(uri).toBe(`github://${owner}/${repo}/${path}?ref=${branch}`);
});
it("fromContentUri parses the github uris correctly", () => {
const contentInfo = GitHubUtils.fromContentUri(`github://${owner}/${repo}/${path}?ref=${branch}`);
expect(contentInfo).toEqual({
owner,
repo,
branch,
path
});
});
});