Chore: fix tests: use UTC in tests

This commit is contained in:
Pieter Vander Vennet 2025-06-12 15:23:48 +02:00
parent dc5a16fb3e
commit cd9901d701

View file

@ -6,6 +6,7 @@ import { expect } from "chai"
describe("OH", () => { describe("OH", () => {
describe("getRanges", () => { describe("getRanges", () => {
process.env.TZ = 'UTC'
it("standard opening hours", () => { it("standard opening hours", () => {
const oh_obj = OH.createOhObject({ const oh_obj = OH.createOhObject({
"opening_hours": "10:00-18:00", "opening_hours": "10:00-18:00",
@ -16,15 +17,16 @@ describe("OH", () => {
expect(ranges[1]).to.deep.equal([ expect(ranges[1]).to.deep.equal([
{ {
"comment": undefined, "comment": undefined,
"endDate": new Date("2025-06-10T16:00:00.000Z"), "endDate": new Date("2025-06-10T18:00:00.000Z"),
"isOpen": true, "isOpen": true,
"isSpecial": false, "isSpecial": false,
"openEnd": false, "openEnd": false,
"startDate": new Date("2025-06-10T08:00:00.000Z"), "startDate": new Date("2025-06-10T10:00:00.000Z"),
}, },
]) ])
}) })
it("open ended opening hours", () => { it("open ended opening hours", () => {
process.env.TZ = 'UTC'
const oh_obj = OH.createOhObject({ const oh_obj = OH.createOhObject({
"opening_hours": "10:00-18:00+", "opening_hours": "10:00-18:00+",
_lat: 0, _lon: 0, _country: "be", _lat: 0, _lon: 0, _country: "be",
@ -34,21 +36,21 @@ describe("OH", () => {
expect(ranges[1]).to.deep.equal([ expect(ranges[1]).to.deep.equal([
{ {
"comment": undefined, "comment": undefined,
"endDate": new Date("2025-06-10T11:00:00.000Z"), "endDate": new Date("2025-06-10T13:00:00.000Z"),
"isOpen": false, "isOpen": false,
"isSpecial": true, "isSpecial": true,
"openEnd": true, "openEnd": true,
"startDate": new Date("2025-06-10T08:00:00.000Z"), "startDate": new Date("2025-06-10T10:00:00.000Z"),
}, },
]) ])
expect(ranges.at(-1)).to.deep.equal([ expect(ranges.at(-1)).to.deep.equal([
{ {
"comment": undefined, "comment": undefined,
"endDate": new Date("2025-06-15T11:00:00.000Z"), "endDate": new Date("2025-06-15T13:00:00.000Z"),
"isOpen": false, "isOpen": false,
"isSpecial": true, "isSpecial": true,
"openEnd": true, "openEnd": true,
"startDate": new Date("2025-06-15T08:00:00.000Z"), "startDate": new Date("2025-06-15T10:00:00.000Z"),
}, },
]) ])
}) })