From c126d080bcae5379e7f48fafff841f137842b5ed Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Fri, 14 Jun 2024 19:06:48 +0200 Subject: [PATCH] Make tests pass on windows OS --- test/bin/tools/crawl.spec.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/test/bin/tools/crawl.spec.ts b/test/bin/tools/crawl.spec.ts index 28449f93..4f88aa19 100644 --- a/test/bin/tools/crawl.spec.ts +++ b/test/bin/tools/crawl.spec.ts @@ -1,4 +1,4 @@ -import path from "path"; +import { join as pathJoin } from "path"; import { it, describe, expect, vi, beforeAll, afterAll } from "vitest"; import { crawl } from "keycloakify/bin/tools/crawl"; @@ -13,11 +13,11 @@ describe("crawl", () => { switch (dir_path) { case "root_dir": return ["sub_1_dir", "file_1", "sub_2_dir", "file_2"]; - case path.join("root_dir", "sub_1_dir"): + case pathJoin("root_dir", "sub_1_dir"): return ["file_3", "sub_3_dir", "file_4"]; - case path.join("root_dir", "sub_1_dir", "sub_3_dir"): + case pathJoin("root_dir", "sub_1_dir", "sub_3_dir"): return ["file_5"]; - case path.join("root_dir", "sub_2_dir"): + case pathJoin("root_dir", "sub_2_dir"): return []; default: { const enoent = new Error( @@ -46,10 +46,12 @@ describe("crawl", () => { }); it("returns files under a given dir_path", async () => { const paths = crawl({ - dirPath: "root_dir/sub_1_dir/sub_3_dir", + dirPath: pathJoin("root_dir", "sub_1_dir", "sub_3_dir"), returnedPathsType: "absolute" }); - expect(paths).toEqual(["root_dir/sub_1_dir/sub_3_dir/file_5"]); + expect(paths).toEqual([ + pathJoin("root_dir", "sub_1_dir", "sub_3_dir", "file_5") + ]); }); it("returns files recursively under a given dir_path", async () => { const paths = crawl({ @@ -57,11 +59,11 @@ describe("crawl", () => { returnedPathsType: "absolute" }); expect(paths).toEqual([ - "root_dir/sub_1_dir/file_3", - "root_dir/sub_1_dir/sub_3_dir/file_5", - "root_dir/sub_1_dir/file_4", - "root_dir/file_1", - "root_dir/file_2" + pathJoin("root_dir", "sub_1_dir", "file_3"), + pathJoin("root_dir", "sub_1_dir", "sub_3_dir", "file_5"), + pathJoin("root_dir", "sub_1_dir", "file_4"), + pathJoin("root_dir", "file_1"), + pathJoin("root_dir", "file_2") ]); }); it("throw dir_path does not exist", async () => {