@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 36 lines 1.46 KB
Raw
1 import * as Glob from "@effect/graphql-generator/internal/Glob"
2 import { assert, describe, it } from "@effect/vitest"
3
4 const assertMatches = (pattern: string, matching: ReadonlyArray<string>, notMatching: ReadonlyArray<string>) => {
5 const glob = Glob.make(pattern)
6 for (const path of matching) assert.isTrue(glob.matches(path), `${pattern} should match ${path}`)
7 for (const path of notMatching) assert.isFalse(glob.matches(path), `${pattern} should not match ${path}`)
8 }
9
10 describe("Glob", () => {
11 it("* matches within one path segment", () => {
12 assertMatches("src/*.graphql", ["src/a.graphql"], ["src/a/b.graphql", "a.graphql", "src/a.gql"])
13 })
14
15 it("** matches any number of segments, including none", () => {
16 assertMatches(
17 "src/**/*.graphql",
18 ["src/a.graphql", "src/x/a.graphql", "src/x/y/z/a.graphql"],
19 ["a.graphql", "lib/a.graphql", "src/a.graphql.ts"]
20 )
21 })
22
23 it("{a,b} matches either alternative", () => {
24 assertMatches("{src,lib}/*.graphql", ["src/a.graphql", "lib/a.graphql"], ["app/a.graphql"])
25 })
26
27 it("an unmatched { is a literal character", () => {
28 assertMatches("src/{q,r.graphql", ["src/{q,r.graphql"], ["src/q.graphql", "src/r.graphql"])
29 })
30
31 it("root is the leading segments before the first wildcard", () => {
32 assert.strictEqual(Glob.make("src/app/**/*.graphql").root, "src/app")
33 assert.strictEqual(Glob.make("./src/*.graphql").root, "src")
34 assert.strictEqual(Glob.make("**/*.graphql").root, "")
35 })
36 })