Odoo18-Base/addons/web/static/tests/reactivity_tests.js
2025-03-10 10:52:11 +07:00

44 lines
1.5 KiB
JavaScript

/** @odoo-module **/
import { reactive, toRaw } from "@odoo/owl";
const {
DateTime,
Duration,
FixedOffsetZone,
IANAZone,
Info,
Interval,
InvalidZone,
Settings,
SystemZone,
Zone,
} = luxon;
QUnit.module("reactivity", () => {
QUnit.test("Luxon objects can't be made reactive", async (assert) => {
const obj = reactive({
DateTime: DateTime.now(),
Duration: Duration.fromObject({ seconds: 10 }),
FixedOffsetZone: FixedOffsetZone.instance(0),
IANAZone: IANAZone.create("CET"),
Info: Info,
Interval: Interval.before(DateTime.now(), { seconds: 10 }),
InvalidZone: new InvalidZone("invalid"),
Settings: new Settings(),
SystemZone: new SystemZone(),
Zone: new Zone(),
});
assert.strictEqual(obj.DateTime, toRaw(obj.DateTime));
assert.strictEqual(obj.Duration, toRaw(obj.Duration));
assert.strictEqual(obj.FixedOffsetZone, toRaw(obj.FixedOffsetZone));
assert.strictEqual(obj.IANAZone, toRaw(obj.IANAZone));
assert.strictEqual(obj.Info, toRaw(obj.Info));
assert.strictEqual(obj.Interval, toRaw(obj.Interval));
assert.strictEqual(obj.InvalidZone, toRaw(obj.InvalidZone));
assert.strictEqual(obj.Settings, toRaw(obj.Settings));
assert.strictEqual(obj.SystemZone, toRaw(obj.SystemZone));
assert.strictEqual(obj.Zone, toRaw(obj.Zone));
});
});