-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add more tests to handlebar templates (#27)
Fun fact, I hate every template engine ever made. Another fun fact, trying to remove items from an array in a pure way is _pure_ pain.
- Loading branch information
Showing
4 changed files
with
33 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { readFile, mkdtemp, rm } from "fs/promises"; | ||
import { afterEach, beforeEach, describe, expect, it } from "vitest"; | ||
import Handlebars from "./handlebars"; | ||
|
||
describe.concurrent("handlebars", () => { | ||
it("can use an or helper function", async (ctx) => { | ||
const template = Handlebars.compile( | ||
"{{#or KEY_ONE KEY_TWO KEY_THREE}}helpers: true{{else}}helpers: false{{/or}}", | ||
); | ||
const result = template({ | ||
KEY_ONE: "false", | ||
KEY_TWO: "false", | ||
KEY_THREE: "true", | ||
}); | ||
|
||
expect(result).toEqual("helpers: true"); | ||
}); | ||
|
||
it("can use an or helper inverse function", async (ctx) => { | ||
const template = Handlebars.compile( | ||
"{{#or KEY_ONE KEY_TWO KEY_THREE}}helpers: true{{else}}helpers: false{{/or}}", | ||
); | ||
const result = template({ | ||
KEY_ONE: undefined, | ||
KEY_TWO: undefined, | ||
KEY_THREE: undefined, | ||
}); | ||
|
||
expect(result).toEqual("helpers: false"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.