From 1edea9326c2617900a7000f6d0dc9b41ee36e641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Fri, 17 Aug 2018 10:37:51 +0200 Subject: [PATCH] [FIX] web: tests: correctly unpatch classes Before this commit, `testUtils.unpatch` was incorrectly unpatching a class' properties. That is caused by restoring the properties on the class function itself, instead of the prototype of the class function. This commit fixes this issue by restoring properties on the prototype function of the class on `testUtils.unpatch`. --- addons/web/static/tests/helpers/test_utils.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/web/static/tests/helpers/test_utils.js b/addons/web/static/tests/helpers/test_utils.js index 37ce9d88fd3..1b9e1ccf57d 100644 --- a/addons/web/static/tests/helpers/test_utils.js +++ b/addons/web/static/tests/helpers/test_utils.js @@ -830,14 +830,17 @@ function patch (target, props) { function unpatch(target) { var patchID = target.__patchID; var patch = patches[patchID]; - _.each(patch.ownPatchedProps, function (p) { - target[p.key] = p.initialValue; - }); if (target.prototype) { + _.each(patch.ownPatchedProps, function (p) { + target.prototype[p.key] = p.initialValue; + }); _.each(patch.otherPatchedProps, function (key) { delete target.prototype[key]; }); } else { + _.each(patch.ownPatchedProps, function (p) { + target[p.key] = p.initialValue; + }); _.each(patch.otherPatchedProps, function (key) { delete target[key]; });