[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:
@@ -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];
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user