///
///
import * as sourceMapSupport from 'source-map-support';
sourceMapSupport.install();
import * as g6 from "../g6.entry";
import * as path from "path";
require('jasmine-expect');
const promise_it = (description: string, action: () => Promise) => {
it(description, function (done) {
action().then(done).catch(error => {
// console.error("error: " + error);
done.fail(error);
})
})
}
var n = false;
describe("a g6", () => {
it("can find the project", async function (done: Function) {
const workspace = await g6.getWorkspace(process.cwd());
const project = workspace.projects[0];
expect(project.name).toBe("g6");
expect(project.package_folder).toEndWith("\\g6");
expect(project.package_path).toEndWith("\\g6\\package.json");
expect(project.version).toBeTruthy();
done();
});
promise_it("does not notice the test project since we hid it inside a node_modules folder", async function () {
var workspace = await g6.getWorkspace(process.cwd());
expect(workspace.projects.length).toBe(1);
});
promise_it("can find the test project ", async function () {
const workspace = await g6.getWorkspace(process.cwd());
const test_folder = path.join(workspace.projects[0].package_folder, "tests/.hidden-for-testing");
const test_workspace = await g6.getWorkspace(test_folder);
const test_project = test_workspace.projects[0];
expect(test_project).toBeTruthy();
expect(test_project.name).toBe("test");
expect(test_project.package_folder).toEndWith("tests\\.hidden-for-testing");
expect(test_project.package_path).toEndWith("tests\\.hidden-for-testing\\package.json");
});
promise_it("can find the child projects in the test project", async function () {
const workspace = await g6.getWorkspace(process.cwd());
const test_workspace = await g6.getWorkspace(path.join(workspace.projects[0].package_folder, "tests/.hidden-for-testing"));
const test_project = test_workspace.projects[0];
const projects = test_workspace.projects;
expect(projects.length).toBe(4);
expect(projects[0].name).toBe("test");
expect(projects[1].name).toBe("child");
expect(projects[1].package_folder).toEndWith("tests\\.hidden-for-testing\\child");
expect(projects[1].package_path).toEndWith("tests\\.hidden-for-testing\\child\\package.json");
expect(projects[2].name).toBe("child.1");
expect(projects[2].package_folder).toEndWith("tests\\.hidden-for-testing\\child.1");
expect(projects[2].package_path).toEndWith("tests\\.hidden-for-testing\\child.1\\package.json");
expect(projects[3].name).toBe("frodo");
expect(projects[3].package_folder).toEndWith("tests\\.hidden-for-testing\\child.1\\child.1.child\\child");
expect(projects[3].package_path).toEndWith("tests\\.hidden-for-testing\\child.1\\child.1.child\\child\\package.json");
});
promise_it("gets the version number for a package", async function () {
const workspace = await g6.getWorkspace(process.cwd());
const test_workspace = await g6.getWorkspace(path.join(workspace.projects[0].package_folder, "tests/.hidden-for-testing"));
expect(test_workspace.getProject("frodo").version).toBe("1.1.12");
expect(test_workspace.getProject("child").version).toBeUndefined();
});
promise_it("can find the dependencies between the child projects in the test project", async function () {
const workspace = await g6.getWorkspace(process.cwd());
const test_workspace = await g6.getWorkspace(path.join(workspace.projects[0].package_folder, "tests/.hidden-for-testing"));
const dependencies = test_workspace.dependencies;
expect(dependencies["test"].length).toBe(0);
expect(dependencies["child"].length).toBe(1);
expect(dependencies["child.1"].length).toBe(2);
expect(dependencies["frodo"].length).toBe(0);
expect(dependencies["child"][0].version).toBe("*");
});
promise_it("can find entry points for the test workspace", async function () {
const workspace = await g6.getWorkspace(process.cwd());
const test_workspace = await g6.getWorkspace(path.join(workspace.projects[0].package_folder, "tests/.hidden-for-testing"));
const entry_points = await test_workspace.getEntryPoints();
expect(entry_points.length).toBe(0);
});
promise_it("can find last modified time", async function () {
const workspace = await g6.getWorkspace(process.cwd());
const project = workspace.projects[0];
const latest_modified = await project.getLastModified();
console.log(latest_modified.toUTCString())
expect(latest_modified).toBeTruthy();
});
// it("can find project last Modified time", async function (done: Function) {
// var workspace = await g6.getWorkspace(process.cwd());
// const project = workspace.projects[0];
// project.getEntryPoints((entry_points: any) => {
// console.log(2);
// expect(entry_points.length).toBe(2);
// console.log(JSON.stringify(entry_points[0].stat));
// expect(entry_points[0].file).toEndWith("\\g6.entry.ts");
// expect(entry_points[1].file).toEndWith("\\tests\\getProjects.spec.node.ts");
// console.log(3);
// done();
// });
// });
// it("uses the dependencies between the child projects in the test project", async function (done: Function) {
// var this_project = await g6.getProject(process.cwd());
// var test_project = await g6.getProject(path.join(this_project.path, "tests/node_modules"));
// var projects = await g6.getProjects(test_project.package_folder);
// var dependencies = g6.getDependencies(projects);
// expect(dependencies["test"].length).toBe(0);
// expect(dependencies["child"].length).toBe(1);
// expect(dependencies["child.1"].length).toBe(2);
// expect(dependencies["frodo"].length).toBe(0);
// done();
// });
});