glob.test.ts
This file
Path
packages/gate/test/glob.test.ts
40 lines · 1.5 KiB · TypeScript
Last changed by
Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503
History of this fileTake it
1234567891011121314151617181920212223242526272829303132333435363738394041import { describe, expect, it } from "@effect/vitest";
import { matchAny, matchGlob } from "../src/glob.ts";
const rows: readonly (readonly [string, string, boolean])[] = [ ["vitest.config.*", "vitest.config.ts", true], ["vitest.config.*", "packages/parse/vitest.config.ts", true], [".github/workflows/**", ".github/workflows/ci.yml", true], [".github/workflows/**", "docs/.github/workflows/ci.yml", false], ["/package.json", "package.json", true], ["/package.json", "packages/parse/package.json", false], ["tools/oxlint/**", "tools/oxlint", true], ["packages/*/src/**", "packages/parse/src/week.ts", true], ["packages/*/src/**", "packages/parse/test/week.test.ts", false], ["a/**/b", "a/b", true], ["a/**/b", "a/x/y/b", true], ["tsconfig*.json", "packages/parse/tsconfig.build.json", true], ["generated/", "generated/skill.md", true], ["generated/", "packages/parse/generated/skill.md", true], ["generated/", "packages/parse/generated.ts", false], ["docs/generated/", "docs/generated/skill.md", true], ["docs/generated/", "packages/docs/generated/skill.md", false],];
describe(matchGlob, () => { it.each(rows)("%s against %s is %s", (glob, path, matches) => { expect(matchGlob(glob, path)).toBe(matches); });});
describe(matchAny, () => { it("takes back out what a !glob names", () => { const env = [".env.*", "!.env.*.local"];
expect([ matchAny(env, ".env.production"), matchAny(env, "apps/web/.env.production.local"), ]).toStrictEqual([true, false]); });});