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

@@ -0,0 +1,49 @@
import { NotebookUtil } from "./NotebookUtil";
import { GitHubUtils } from "../../Utils/GitHubUtils";
const fileName = "file";
const notebookName = "file.ipynb";
const filePath = `folder/${fileName}`;
const notebookPath = `folder/${notebookName}`;
const gitHubFileUri = GitHubUtils.toContentUri("owner", "repo", "branch", filePath);
const gitHubNotebookUri = GitHubUtils.toContentUri("owner", "repo", "branch", notebookPath);
describe("NotebookUtil", () => {
describe("isNotebookFile", () => {
it("works for jupyter file paths", () => {
expect(NotebookUtil.isNotebookFile(filePath)).toBeFalsy();
expect(NotebookUtil.isNotebookFile(notebookPath)).toBeTruthy();
});
it("works for github file uris", () => {
expect(NotebookUtil.isNotebookFile(gitHubFileUri)).toBeFalsy();
expect(NotebookUtil.isNotebookFile(gitHubNotebookUri)).toBeTruthy();
});
});
describe("getName", () => {
it("works for jupyter file paths", () => {
expect(NotebookUtil.getName(filePath)).toEqual(fileName);
expect(NotebookUtil.getName(notebookPath)).toEqual(notebookName);
});
it("works for github file uris", () => {
expect(NotebookUtil.getName(gitHubFileUri)).toEqual(fileName);
expect(NotebookUtil.getName(gitHubNotebookUri)).toEqual(notebookName);
});
});
describe("replaceName", () => {
it("works for jupyter file paths", () => {
expect(NotebookUtil.replaceName(filePath, "newName")).toEqual(filePath.replace(fileName, "newName"));
expect(NotebookUtil.replaceName(notebookPath, "newName")).toEqual(notebookPath.replace(notebookName, "newName"));
});
it("works for github file uris", () => {
expect(NotebookUtil.replaceName(gitHubFileUri, "newName")).toEqual(gitHubFileUri.replace(fileName, "newName"));
expect(NotebookUtil.replaceName(gitHubNotebookUri, "newName")).toEqual(
gitHubNotebookUri.replace(notebookName, "newName")
);
});
});
});