diff options
| author | Vincent Schippefilt <vsc@odoo.com> | 2019-03-06 14:02:32 +0100 |
|---|---|---|
| committer | Aaron Bohy <aab@odoo.com> | 2019-03-06 20:07:17 +0100 |
| commit | ab56e637b7f97ddcdbcc9baea99ae097e342409c (patch) | |
| tree | 4cb47da9f7ef89b19d18429220a7507470ec12a9 /addons/web/static/tests/helpers/test_utils_mock.js | |
| parent | eeed894fd50e477135e1ac9a82f6e98ce063ab90 (diff) | |
[REF] web: 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/web/static/tests/helpers/test_utils_mock.js')
| -rw-r--r-- | addons/web/static/tests/helpers/test_utils_mock.js | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/addons/web/static/tests/helpers/test_utils_mock.js b/addons/web/static/tests/helpers/test_utils_mock.js index 2ecc655db7e..ccb4d20959e 100644 --- a/addons/web/static/tests/helpers/test_utils_mock.js +++ b/addons/web/static/tests/helpers/test_utils_mock.js @@ -124,7 +124,7 @@ function removeSrcAttribute(el, widget) { * is completely removed by default. * * @returns {MockServer} the instance of the mock server, created by this - * function. It is necessary for createAsyncView so that method can call some + * function. It is necessary for createView so that method can call some * other methods on it. */ function addMockEnvironment(widget, params) { @@ -199,10 +199,11 @@ function addMockEnvironment(widget, params) { // widget is destroyed, at the end of each test to avoid collisions core.bus.trigger('clear_cache'); - _(services).chain() - .compact() // services can be defined but null (e.g. ajax) - .reject(function (s) { return s.isDestroyed(); }) - .invoke('destroy'); + Object.keys(services).forEach(function(s) { + var service = services[s]; + if (service && !service.isDestroyed()) + service.destroy(); + }); DebouncedField.prototype.DEBOUNCE = initialDebounceValue; dom.DEBOUNCE = initialDOMDebounceValue; @@ -543,6 +544,25 @@ function unpatch(target) { delete target.__patchID; } +window.originalSetTimeout = window.setTimeout; +function patchSetTimeout() { + var original = window.setTimeout; + var self = this; + window.setTimeout = function (handler, delay) { + console.log("calling setTimeout on " + (handler.name || "some function") + "with delay of " + delay); + console.trace(); + var handlerArguments = Array.prototype.slice.call(arguments, 1); + return original(function () { + handler.bind(self, handlerArguments)(); + console.log('after doing the action of the setTimeout'); + }, delay); + }; + + return function () { + window.setTimeout = original; + }; +} + return { addMockEnvironment: addMockEnvironment, @@ -551,6 +571,7 @@ return { patchDate: patchDate, patch: patch, unpatch: unpatch, + patchSetTimeout: patchSetTimeout, }; }); |
