diff --git a/addons/mail/static/src/js/models/utils/timer.js b/addons/mail/static/src/js/models/utils/timer.js index a3236fd1a16..9aaae471d2d 100644 --- a/addons/mail/static/src/js/models/utils/timer.js +++ b/addons/mail/static/src/js/models/utils/timer.js @@ -13,7 +13,7 @@ var Timer = Class.extend({ * initialization (@see start method). * * @param {Object} params - * @param {integer} params.duration duration of timer before timeout in + * @param {number} params.duration duration of timer before timeout in * milli-seconds. * @param {function} params.onTimeout function that is called when the * timer times out. diff --git a/addons/mail/static/tests/models/timer_tests.js b/addons/mail/static/tests/models/timer_tests.js index 9a66e80ad22..1a4e7c2726f 100644 --- a/addons/mail/static/tests/models/timer_tests.js +++ b/addons/mail/static/tests/models/timer_tests.js @@ -3,6 +3,7 @@ odoo.define('mail.model.TimerTests', function (require) { var testUtils = require("web.test_utils"); var Timer = require('mail.model.Timer'); +var concurrency = require('web.concurrency'); QUnit.module('mail', {}, function () { QUnit.module('model', {}, function () { @@ -20,9 +21,8 @@ QUnit.test('start()', async function (assert) { assert.verifySteps([], "should not have called the function"); t.start(); - await prom.then(function () { - assert.ok(true, "should have called the function"); - }); + await prom; + assert.ok(true, "should have called the function"); }); QUnit.test('clear()', function (assert) { @@ -44,15 +44,17 @@ QUnit.test('clear()', function (assert) { setTimeout(function () { assert.verifySteps([], "should not have called the function"); done(); - }, 0); + }, 1); }); QUnit.test('reset()', async function (assert) { assert.expect(4); - var prom = testUtils.makeTestPromise(); + var i = 0; + var func = function () { - assert.step('function_called'); + ++i; + assert.step('function_called ' + i); }; var t = new Timer({ duration: 0, @@ -62,18 +64,14 @@ QUnit.test('reset()', async function (assert) { t.start(); // Called after 1st timer timeout - await testUtils.nextTick(); - assert.verifySteps(['function_called'], "should have called the function once"); + await concurrency.delay(1); + assert.verifySteps(['function_called 1'], "should have called the function once"); t.reset(); + // Called after 2nd timer timeout - setTimeout(function () { - prom.resolve(); - }, 0); - - await prom.then(function () { - assert.verifySteps(['function_called'], - "should have called the function twice (2nd time from reset)"); - }); + await concurrency.delay(1); + assert.verifySteps(['function_called 2'], + "should have called the function twice (2nd time from reset)"); }); }); diff --git a/addons/mail/static/tests/models/timers_tests.js b/addons/mail/static/tests/models/timers_tests.js index eeaf2e2a8f6..ccc15c4b69d 100644 --- a/addons/mail/static/tests/models/timers_tests.js +++ b/addons/mail/static/tests/models/timers_tests.js @@ -60,7 +60,7 @@ QUnit.test('register timers once per ID', function (assert) { setTimeout(function () { assert.verifySteps(['function_called'], "should have called the function once"); done(); - }, 0); + }, 1); }); QUnit.test('unregister timers', function (assert) { @@ -82,7 +82,7 @@ QUnit.test('unregister timers', function (assert) { setTimeout(function () { assert.verifySteps([], "should not have called the function"); done(); - }, 0); + }, 1); }); });