From f1e0c5e3ee740ea2c0c69d4d168d0f23cf9ff700 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 4 Mar 2020 15:23:24 +0100 Subject: [PATCH] =?UTF-8?q?test:=20=F0=9F=9A=A8=20fixed=20tests=20for=20Wi?= =?UTF-8?q?n32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/git.ts | 12 ++++++++---- __tests__/package.ts | 15 +++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/__tests__/git.ts b/__tests__/git.ts index 94c0c520..d34dd2ca 100644 --- a/__tests__/git.ts +++ b/__tests__/git.ts @@ -3,6 +3,10 @@ import path from "path" const workspaceRoot = path.resolve(__dirname, "workspace") +function f(file: string) { + return file.replace(/\\/gu, "/") +} + test("parseGitFiles", () => { const data = `C libs C foo @@ -28,10 +32,10 @@ H 100644 afcd42dfe13cb03ac1cdf0f7843188bdb6cbdb66 0 package.json` test("getGitFiles", async () => { const files = await getGitFiles(path.resolve(workspaceRoot, "apps")) - expect(files["__tests__/workspace/apps/app1/package.json"]).toMatch( + expect(files[f("__tests__/workspace/apps/app1/package.json")]).toMatch( /^[a-z0-9]*$/u ) - expect(files["__tests__/workspace/apps/app2/package.json"]).toMatch( + expect(files[f("__tests__/workspace/apps/app2/package.json")]).toMatch( /^[a-z0-9]*$/u ) expect(files[""]).toMatch(/^\d+\.\d+$/u) @@ -41,8 +45,8 @@ test("getGitFiles", async () => { test("cache", async () => { const files = await cache.getFiles(path.resolve(workspaceRoot, "apps")) - expect(files["app1/package.json"]).toMatch(/^[a-z0-9]*$/u) - expect(files["app2/package.json"]).toMatch(/^[a-z0-9]*$/u) + expect(files[f("app1/package.json")]).toMatch(/^[a-z0-9]*$/u) + expect(files[f("app2/package.json")]).toMatch(/^[a-z0-9]*$/u) expect(Object.keys(files)).toHaveLength(2) expect(cache.cache.size).not.toBe(0) await cache.getFiles(path.resolve(workspaceRoot, "apps")) diff --git a/__tests__/package.ts b/__tests__/package.ts index db215fcc..631d18a8 100644 --- a/__tests__/package.ts +++ b/__tests__/package.ts @@ -1,6 +1,10 @@ import { findPackages, findUp, getPackage } from "../src/package" import path from "path" +function fa(files: string[]) { + return files.map(f => f.replace(/\\/gu, "/")) +} + test("findPackages without options ", async () => { const root = path.resolve("__tests__/workspace") const packages = ( @@ -10,14 +14,9 @@ test("findPackages without options ", async () => { ) .map(p => path.relative(root, p)) .sort() - expect(packages).toStrictEqual([ - "", - "apps/app1", - "apps/app2", - "libs/lib1", - "libs/lib2", - "libs/lib3", - ]) + expect(packages).toStrictEqual( + fa(["", "apps/app1", "apps/app2", "libs/lib1", "libs/lib2", "libs/lib3"]) + ) }) test("findUp", () => {