Files
odoo_source/addons/mail/static/tests/clock_model_tests.js
T
Louis Wicket (wil) 24a19a10c9 [IMP] mail: delete time model, add clock and clock watcher models
The Time model is deleted and replaced with the new Clock model. The
differences are that there can be several clocks, whereas Time was a
singleton, and that a clock must define the frequency at which it
updates.

The new model ClockWatcher is added to model a record that makes use of
a clock. This is currently useful for the clocks to set or clear intervals
as needed.

closes odoo/odoo#86219

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-03-14 10:38:11 +00:00

43 lines
1.2 KiB
JavaScript

/** @odoo-module **/
import { insertAndReplace } from '@mail/model/model_field_command';
import { afterEach, beforeEach, start } from '@mail/utils/test_utils';
QUnit.module('mail', {}, function () {
QUnit.module('clock_model_tests', {
async beforeEach() {
await beforeEach(this);
this.start = async params => {
const res = await start({ ...params, data: this.data });
const { apps, env, widget } = res;
this.apps = apps;
this.env = env;
this.widget = widget;
return res;
};
},
afterEach() {
afterEach(this);
},
});
QUnit.test('Deleting all the watchers of a clock should result in the deletion of the clock itself.', async function (assert) {
assert.expect(1);
await this.start();
const watcher = this.messaging.models['ClockWatcher'].insert({
clock: insertAndReplace({ frequency: 180 * 1000 }),
qunitTestOwner: insertAndReplace(),
});
const { clock } = watcher;
watcher.delete();
assert.notOk(
clock.exists(),
"deleting all the watchers of a clock should result in the deletion of the clock itself."
);
});
});