Updating test.

This commit is contained in:
mike12345567 2021-06-09 12:11:40 +01:00
parent 310ed3aefc
commit f9ba157f97
1 changed files with 5 additions and 4 deletions

View File

@ -163,7 +163,7 @@ describe("test the date helpers", () => {
it("should allow use of the date helper", async () => { it("should allow use of the date helper", async () => {
const date = new Date(1611577535000) const date = new Date(1611577535000)
const output = await processString("{{ date time 'YYYY-MM-DD' }}", { const output = await processString("{{ date time 'YYYY-MM-DD' }}", {
time: date.toISOString(), time: date.toUTCString(),
}) })
expect(output).toBe("2021-01-25") expect(output).toBe("2021-01-25")
}) })
@ -177,15 +177,16 @@ describe("test the date helpers", () => {
it("should test the timezone capabilities", async () => { it("should test the timezone capabilities", async () => {
const date = new Date(1611577535000) const date = new Date(1611577535000)
const output = await processString("{{ date time 'HH-mm-ss Z' 'America/New_York' }}", { const output = await processString("{{ date time 'HH-mm-ss Z' 'America/New_York' }}", {
time: date.toISOString(), time: date.toUTCString(),
}) })
expect(output).toBe("07-25-35 -04:00") const formatted = new dayjs(date).tz("America/New_York").format("HH-mm-ss Z")
expect(output).toBe(formatted)
}) })
it("should guess the users timezone when not specified", async () => { it("should guess the users timezone when not specified", async () => {
const date = new Date() const date = new Date()
const output = await processString("{{ date time 'Z' }}", { const output = await processString("{{ date time 'Z' }}", {
time: date.toISOString() time: date.toUTCString()
}) })
const timezone = dayjs.tz.guess() const timezone = dayjs.tz.guess()
const offset = new dayjs(date).tz(timezone).format("Z") const offset = new dayjs(date).tz(timezone).format("Z")