Swap-Aggregator-Subgraph/node_modules/fs-jetpack/spec/path.spec.ts
Richa-iitr d211083153 Revert "Revert "added handler""
This reverts commit c36ee8c5ca.
2022-07-03 07:30:05 +05:30

30 lines
1.0 KiB
TypeScript

import * as pathUtil from "path";
import { expect } from "chai";
import * as jetpack from "..";
describe("path", () => {
it("if no parameters passed returns same path as cwd()", () => {
expect(jetpack.path()).to.equal(jetpack.cwd());
expect(jetpack.path("")).to.equal(jetpack.cwd());
expect(jetpack.path(".")).to.equal(jetpack.cwd());
});
it("is absolute if prepending slash present", () => {
expect(jetpack.path("/blah")).to.equal(pathUtil.resolve("/blah"));
});
it("resolves to CWD path of this jetpack instance", () => {
const a = pathUtil.join(jetpack.cwd(), "a");
// Create jetpack instance with other CWD
const jetpackSubdir = jetpack.cwd("subdir");
const b = pathUtil.join(jetpack.cwd(), "subdir", "b");
expect(jetpack.path("a")).to.equal(a);
expect(jetpackSubdir.path("b")).to.equal(b);
});
it("can take unlimited number of arguments as path parts", () => {
const abc = pathUtil.join(jetpack.cwd(), "a", "b", "c");
expect(jetpack.path("a", "b", "c")).to.equal(abc);
});
});