diff options
| author | Vincent Schippefilt <vsc@odoo.com> | 2019-03-06 14:02:19 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-03-06 20:07:17 +0100 |
| commit | 1ae64793fa489b2c1d07408cd9671bc7126f78fa (patch) | |
| tree | 23d908222f4e705b908dd23ef3823c26daf3baf0 /addons/mail/static/tests/models/timer_tests.js | |
| parent | aa900d976f6fbb10f3940639b4d918d31a7556ca (diff) | |
[REF] mail: adapt code after jQuery update
Part of task 1896658
Co-authored-by: Aaron Bohy <aab@odoo.com>
Co-authored-by: Christophe Matthieu <chm@odoo.com>
Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com>
Co-authored-by: David Monjoie <dmo@odoo.com>
Co-authored-by: Martin Geubelle <mge@odoo.com>
Co-authored-by: svs-odoo <svs@odoo.com>
Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Diffstat (limited to 'addons/mail/static/tests/models/timer_tests.js')
| -rw-r--r-- | addons/mail/static/tests/models/timer_tests.js | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/addons/mail/static/tests/models/timer_tests.js b/addons/mail/static/tests/models/timer_tests.js index 535c5649ec9..9a66e80ad22 100644 --- a/addons/mail/static/tests/models/timer_tests.js +++ b/addons/mail/static/tests/models/timer_tests.js @@ -1,31 +1,27 @@ odoo.define('mail.model.TimerTests', function (require) { "use strict"; +var testUtils = require("web.test_utils"); var Timer = require('mail.model.Timer'); QUnit.module('mail', {}, function () { QUnit.module('model', {}, function () { QUnit.module('Timer'); -QUnit.test('start()', function (assert) { - var done = assert.async(); +QUnit.test('start()', async function (assert) { assert.expect(2); - var def = $.Deferred(); - var func = function () { - def.resolve(); - }; + var prom = testUtils.makeTestPromise(); var t = new Timer({ duration: 0, - onTimeout: func, + onTimeout: prom.resolve, }); assert.verifySteps([], "should not have called the function"); t.start(); - def.then(function () { + await prom.then(function () { assert.ok(true, "should have called the function"); - done(); }); }); @@ -51,11 +47,10 @@ QUnit.test('clear()', function (assert) { }, 0); }); -QUnit.test('reset()', function (assert) { - var done = assert.async(); +QUnit.test('reset()', async function (assert) { assert.expect(4); - var def = $.Deferred(); + var prom = testUtils.makeTestPromise(); var func = function () { assert.step('function_called'); }; @@ -67,19 +62,17 @@ QUnit.test('reset()', function (assert) { t.start(); // Called after 1st timer timeout + await testUtils.nextTick(); + assert.verifySteps(['function_called'], "should have called the function once"); + t.reset(); + // Called after 2nd timer timeout setTimeout(function () { - assert.verifySteps(['function_called'], "should have called the function once"); - t.reset(); - // Called after 2nd timer timeout - setTimeout(function () { - def.resolve(); - }, 0); + prom.resolve(); }, 0); - def.then(function () { - assert.verifySteps(['function_called', 'function_called'], + await prom.then(function () { + assert.verifySteps(['function_called'], "should have called the function twice (2nd time from reset)"); - done(); }); }); |
