[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`.
This commit is contained in:
Alexandre Kühn
2018-08-17 16:20:06 +02:00
parent bb5a9a6ae6
commit 1edea9326c
@@ -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];
});