From 71716092a6acb32e76070adfdd7b3da578f55ee7 Mon Sep 17 00:00:00 2001 From: anikethsaha Date: Sat, 6 Jul 2019 18:02:24 +0530 Subject: [PATCH 1/2] tests: added tests for path-utils --- packages/utils/__tests__/path-utils.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 packages/utils/__tests__/path-utils.test.ts diff --git a/packages/utils/__tests__/path-utils.test.ts b/packages/utils/__tests__/path-utils.test.ts new file mode 100644 index 00000000000..e67e009b7b4 --- /dev/null +++ b/packages/utils/__tests__/path-utils.test.ts @@ -0,0 +1,13 @@ +import { join } from "path"; +import { isLocalPath, findProjectRoot } from "../path-utils"; + +describe("path-utils tests", () => { + it("isLocalPath Testing : __dirname", () => { + const answer = isLocalPath(join(__dirname, "../../")); + expect(answer).toBe(true); + }); + it("findProjectRoot testing", () => { + const answer = findProjectRoot(); + expect(answer).toBe(process.cwd()); + }); +}); From b9c4260c40d50a3ae68a4a9a4b7f02554a3d162d Mon Sep 17 00:00:00 2001 From: anikethsaha Date: Sun, 14 Jul 2019 01:11:37 +0530 Subject: [PATCH 2/2] chore: added more tests for path-utils --- packages/utils/__tests__/path-utils.test.ts | 41 +++++++++++++++++---- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/packages/utils/__tests__/path-utils.test.ts b/packages/utils/__tests__/path-utils.test.ts index e67e009b7b4..facfde06d84 100644 --- a/packages/utils/__tests__/path-utils.test.ts +++ b/packages/utils/__tests__/path-utils.test.ts @@ -2,12 +2,37 @@ import { join } from "path"; import { isLocalPath, findProjectRoot } from "../path-utils"; describe("path-utils tests", () => { - it("isLocalPath Testing : __dirname", () => { - const answer = isLocalPath(join(__dirname, "../../")); - expect(answer).toBe(true); - }); - it("findProjectRoot testing", () => { - const answer = findProjectRoot(); - expect(answer).toBe(process.cwd()); - }); + it("isLocalPath Testing : __dirname", () => { + const answer = isLocalPath(join(__dirname, "../../")); + expect(answer).toBe(true); + }); + it("findProjectRoot testing", () => { + const answer = findProjectRoot(); + expect(answer).toBe(process.cwd()); + }); + it("isLocalPath Testing : ../types", () => { + const answer = isLocalPath(join(__dirname, "../types")); + expect(answer).toBe(true); + }); + it("isLocalPath Testing : ../notLocalPath", () => { + const answer = isLocalPath("../notLocalPath"); + expect(answer).toBe(false); + }); + it("isLocalPath Testing : ../notLocalPath using path.join", () => { + const answer = isLocalPath(join(__dirname, "../notLocalPath")); + expect(answer).toBe(false); + }); + it("isLocalPath Testing : ./_snapshots (./path)", () => { + const answer = isLocalPath(join(__dirname, "./__snapshots__")); + expect(answer).toBe(true); + }); + + it("isLocalPath Testing : /_snapshots/ast-utils.test.ts.snap (path/path)", () => { + const answer = isLocalPath(join(__dirname, "/__snapshots__/ast-utils.test.ts.snap")); + expect(answer).toBe(true); + }); + it("isLocalPath Testing : ..\\ win", () => { + const answer = isLocalPath("..\\"); + expect(answer).toBe(true); + }); });