summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfwi-odoo <fwi@odoo.com>2017-11-16 10:24:15 +0100
committerfwi-odoo <fwi@odoo.com>2017-11-17 10:52:11 +0100
commit9cbf0c87e2d6705d72ca4613f761b6b2b9901afd (patch)
tree267e2f6e9939c474b371d250a312e998d3200b0b
parent54c2c087478036dc2edcfe8084f388217b179971 (diff)
[FIX] web: allow to reexecute functions using _.throttle in the js tests
Before this commit, it was not possible to reexecute functions using the _.throttle function in the same test (e.g. drag and drop two elements in the studio tests).
-rw-r--r--addons/web/static/tests/helpers/qunit_config.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/addons/web/static/tests/helpers/qunit_config.js b/addons/web/static/tests/helpers/qunit_config.js
index 641d3a6f09b..8d2b287ab88 100644
--- a/addons/web/static/tests/helpers/qunit_config.js
+++ b/addons/web/static/tests/helpers/qunit_config.js
@@ -41,6 +41,17 @@ QUnit.config.hidepassed = (window.location.href.match(/[?&]testId=/) === null);
var sortButtonAppended = false;
/**
+ * We override the _.throttle function to avoid the delay in order to be able to
+ * chain multiple actions using throttle in the same test.
+ */
+QUnit.begin(function () {
+ this._initialThrottle = _.throttle;
+ var self = this;
+ _.throttle = function (func, wait, options) {
+ return self._initialThrottle(func, 0, options);
+ };
+});
+/**
* This is the way the testing framework knows that tests passed or failed. It
* only look in the phantomJS console and check if there is a ok or an error.
*
@@ -56,6 +67,7 @@ QUnit.done(function(result) {
if (!sortButtonAppended) {
_addSortButton();
}
+ _.throttle = this._initialThrottle;
});
/**