UNPKG

1.05 kBPlain TextView Raw
1import * as pathUtil from "path";
2import { expect } from "chai";
3import * as jetpack from "..";
4
5describe("path", () => {
6 it("if no parameters passed returns same path as cwd()", () => {
7 expect(jetpack.path()).to.equal(jetpack.cwd());
8 expect(jetpack.path("")).to.equal(jetpack.cwd());
9 expect(jetpack.path(".")).to.equal(jetpack.cwd());
10 });
11
12 it("is absolute if prepending slash present", () => {
13 expect(jetpack.path("/blah")).to.equal(pathUtil.resolve("/blah"));
14 });
15
16 it("resolves to CWD path of this jetpack instance", () => {
17 const a = pathUtil.join(jetpack.cwd(), "a");
18 // Create jetpack instance with other CWD
19 const jetpackSubdir = jetpack.cwd("subdir");
20 const b = pathUtil.join(jetpack.cwd(), "subdir", "b");
21 expect(jetpack.path("a")).to.equal(a);
22 expect(jetpackSubdir.path("b")).to.equal(b);
23 });
24
25 it("can take unlimited number of arguments as path parts", () => {
26 const abc = pathUtil.join(jetpack.cwd(), "a", "b", "c");
27 expect(jetpack.path("a", "b", "c")).to.equal(abc);
28 });
29});