replace regex based directive scanner
This commit is contained in:
@@ -590,3 +590,68 @@ test("if neq in path", () => {
|
||||
render(tmp,{test:"test"})
|
||||
expect(existsSync(join(tmp,"not-test"))).toBe(false)
|
||||
})
|
||||
|
||||
test("if neq multiline block", () => {
|
||||
const createRenderer = initRenderer("./testdata/neq_multiline_block")
|
||||
const render = createRenderer(z.object({
|
||||
project: z.object({
|
||||
frontend: z.string()
|
||||
})
|
||||
}))
|
||||
|
||||
render(tmp,{project:{frontend:"react"}})
|
||||
expect(readFileSync(join(tmp,"test.txt"), "utf-8")).toContain("bun dev")
|
||||
|
||||
render(tmp,{project:{frontend:"none"}})
|
||||
expect(readFileSync(join(tmp,"test.txt"), "utf-8")).not.toContain("bun dev")
|
||||
})
|
||||
|
||||
test("and or in file", () => {
|
||||
const createRenderer = initRenderer("./testdata/and_or_in_file")
|
||||
expect(() => createRenderer(z.object({
|
||||
enabled: z.boolean(),
|
||||
fallback: z.boolean(),
|
||||
kind: z.boolean()
|
||||
}))).toThrow(SchemaMismatchError)
|
||||
|
||||
const render = createRenderer(z.object({
|
||||
enabled: z.boolean(),
|
||||
fallback: z.boolean(),
|
||||
kind: z.string()
|
||||
}))
|
||||
|
||||
render(tmp,{enabled:true, fallback:false, kind:"web"})
|
||||
let content = readFileSync(join(tmp,"test.txt"), "utf-8")
|
||||
expect(content).toContain("and")
|
||||
expect(content).toContain("or")
|
||||
expect(content).toContain("nested")
|
||||
|
||||
render(tmp,{enabled:false, fallback:true, kind:"web"})
|
||||
content = readFileSync(join(tmp,"test.txt"), "utf-8")
|
||||
expect(content).toContain("not-and")
|
||||
expect(content).toContain("not-or")
|
||||
expect(content).toContain("nested")
|
||||
|
||||
render(tmp,{enabled:false, fallback:true, kind:"docs"})
|
||||
content = readFileSync(join(tmp,"test.txt"), "utf-8")
|
||||
expect(content).toContain("not-and")
|
||||
expect(content).toContain("or")
|
||||
expect(content).toContain("nested")
|
||||
})
|
||||
|
||||
test("and or in path", () => {
|
||||
const createRenderer = initRenderer("./testdata/and_or_in_path")
|
||||
const render = createRenderer(z.object({
|
||||
enabled: z.boolean(),
|
||||
kind: z.string()
|
||||
}))
|
||||
|
||||
render(tmp,{enabled:true, kind:"web"})
|
||||
expect(existsSync(join(tmp,"match"))).toBe(true)
|
||||
|
||||
render(tmp,{enabled:true, kind:"docs"})
|
||||
expect(existsSync(join(tmp,"match"))).toBe(true)
|
||||
|
||||
render(tmp,{enabled:false, kind:"docs"})
|
||||
expect(existsSync(join(tmp,"match"))).toBe(false)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user