feat: support calling date without format string, #573

This commit is contained in:
Harttle
2023-01-03 00:53:33 +08:00
committed by Harttle
parent 964e5e8961
commit aafaa0b4f9
4 changed files with 32 additions and 5 deletions
+4 -2
View File
@@ -8,11 +8,13 @@ export function render (src: string, ctx?: object) {
return liquid.parseAndRender(src, ctx)
}
export async function test (src: string, ctx: object | string, expected?: string, opts?: LiquidOptions) {
export async function test (src: string, ctx: object | string, expected?: string | RegExp, opts?: LiquidOptions) {
if (expected === undefined) {
expected = ctx as string
ctx = {}
}
const engine = opts ? new Liquid(opts) : liquid
return expect(await engine.parseAndRender(src, ctx as object)).to.equal(expected)
const result = await engine.parseAndRender(src, ctx as object)
if (expected instanceof RegExp) return expect(result).to.match(expected)
return expect(result).to.equal(expected)
}