Skip to content

Commit

Permalink
test: 🚨 fixed tests for Win32
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Mar 4, 2020
1 parent ca06588 commit f1e0c5e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
12 changes: 8 additions & 4 deletions __tests__/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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"))
Expand Down
15 changes: 7 additions & 8 deletions __tests__/package.ts
Original file line number Diff line number Diff line change
@@ -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 = (
Expand All @@ -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", () => {
Expand Down

0 comments on commit f1e0c5e

Please sign in to comment.