fix: support timezoneOffset for date from scope, #401

This commit is contained in:
Harttle
2021-10-06 15:45:41 +08:00
parent 4f6b88c154
commit fd5ef474c3
11 changed files with 132 additions and 53 deletions
+6
View File
@@ -0,0 +1,6 @@
export class DateWithTimezone extends Date {
constructor (init: string, timezone: number) {
super(init)
this.getTimezoneOffset = () => timezone
}
}
+4 -4
View File
@@ -8,11 +8,11 @@ export function render (src: string, ctx?: object) {
return liquid.parseAndRender(src, ctx)
}
export async function test (src: string, ctx: object | string, dst?: string, opts?: LiquidOptions) {
if (dst === undefined) {
dst = ctx as string
export async function test (src: string, ctx: object | string, expected?: string, 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(dst)
return expect(await engine.parseAndRender(src, ctx as object)).to.equal(expected)
}