2020-06-23 16:45:51 +01:00
|
|
|
import * as GitHubUtils from "./GitHubUtils";
|
2020-05-26 03:30:55 +01:00
|
|
|
|
2020-05-26 19:53:41 +01:00
|
|
|
const owner = "owner-1";
|
|
|
|
const repo = "repo-1";
|
|
|
|
const branch = "branch/name.1-2";
|
|
|
|
const path = "folder name/file name1:2.ipynb";
|
2020-05-26 03:30:55 +01:00
|
|
|
|
2020-05-26 19:53:41 +01:00
|
|
|
describe("GitHubUtils", () => {
|
|
|
|
it("fromRepoUri parses github repo url correctly", () => {
|
|
|
|
const repoInfo = GitHubUtils.fromRepoUri(`https://github.com/${owner}/${repo}/tree/${branch}`);
|
|
|
|
expect(repoInfo).toEqual({
|
|
|
|
owner,
|
|
|
|
repo,
|
|
|
|
branch
|
2020-05-26 03:30:55 +01:00
|
|
|
});
|
2020-05-26 19:53:41 +01:00
|
|
|
});
|
2020-05-26 03:30:55 +01:00
|
|
|
|
2020-05-26 19:53:41 +01:00
|
|
|
it("toContentUri generates github uris correctly", () => {
|
|
|
|
const uri = GitHubUtils.toContentUri(owner, repo, branch, path);
|
|
|
|
expect(uri).toBe(`github://${owner}/${repo}/${path}?ref=${branch}`);
|
2020-05-26 03:30:55 +01:00
|
|
|
});
|
|
|
|
|
2020-05-26 19:53:41 +01:00
|
|
|
it("fromContentUri parses the github uris correctly", () => {
|
|
|
|
const contentInfo = GitHubUtils.fromContentUri(`github://${owner}/${repo}/${path}?ref=${branch}`);
|
|
|
|
expect(contentInfo).toEqual({
|
|
|
|
owner,
|
|
|
|
repo,
|
|
|
|
branch,
|
|
|
|
path
|
|
|
|
});
|
2020-05-26 03:30:55 +01:00
|
|
|
});
|
|
|
|
});
|