import EkoProject from "../../classes/EkoProject"; import * as path from "path"; jest.mock("fs"); describe("converting a project's URI to a project path using the getProjectPath method", () => { const ekoProject = new EkoProject(); const projectRootFolder = ekoProject.rootFolder; it("should return NULL given a path that is not a valid URI.", () => { const projectPath = ekoProject.getPath(123); expect(projectPath).toBeNull(); }); it(`should return NULL given a valid raw path that DOES NOT contain the project root folder (${projectRootFolder}/).`, () => { const projectPath = ekoProject.getPath('file:///my-checkouts/checkout_0/dist/js/app.js'); expect(projectPath).toBeNull(); }); describe(`given a valid URI that contains the project root folder (${projectRootFolder}/)`, () => { it("should return a project path if the root folder contains _eko_", () => { require("fs").__setMockFiles({ testItems: ["js", "_eko_", "templates"] }); const projectPath = ekoProject.getPath(`file:///c%3A/my-checkouts/checkout_0/${projectRootFolder}/js/app.js`); const expectedProjectPath = path.normalize('c:/my-checkouts/checkout_0/src'); expect(projectPath).toEqual(expectedProjectPath); }); it("should return NULL if the root folder DOES NOT contain _eko_", () => { require("fs").__setMockFiles({ testItems: ["js", "_not_eko_", "templates"] }); const projectPath = ekoProject.getPath(`file:///c%3A/my-checkouts/checkout_0/${projectRootFolder}/js/app.js`); expect(projectPath).toBeNull(); }); }); });