Files
odoo_source/addons/mail/static/tests/clock_model_tests.js
T
tsm-odoo b15959cd95 [IMP] mail, *: make start method handle cleanup
*: calendar, hr, hr_holidays, im_livechat, mail, mail_bot, note, sms, snailmail,
website_livechat, website_slides.

This commit prepares the removal of beforeEach function in the
mail test suite. Cleanup was relying on beforeEach adding widgets,
components, unpatch method 'this'. We need to clean things up without
using either beforeEach or 'this'.

task-2792108

closes odoo/odoo#86526

Related: odoo/enterprise#25326
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
2022-03-16 16:07:58 +01:00

40 lines
1.1 KiB
JavaScript

/** @odoo-module **/
import { insertAndReplace } from '@mail/model/model_field_command';
import { 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;
};
},
});
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."
);
});
});