Skip to content

Commit

Permalink
Add test for issue #1026
Browse files Browse the repository at this point in the history
  • Loading branch information
mroderick authored and fatso83 committed Dec 17, 2016
1 parent 8663746 commit 9d6ae3b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions test/issues/issues-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,38 @@

sandbox.restore();
}
},

"#1026 - should stub watch method on any Object": function () {
// makes sure that Object.prototype.watch is set back to its old value
function restore(oldWatch) {
if (oldWatch) {
Object.prototype.watch = oldWatch; // eslint-disable-line no-extend-native
} else {
delete Object.prototype.watch;
}
}

try {
var oldWatch = Object.prototype.watch;

if (typeof Object.prototype.watch !== "function") {
Object.prototype.watch = function rolex() {}; // eslint-disable-line no-extend-native
}

var stubbedObject = sinon.stub({
watch: function () {}
});

stubbedObject.watch();

assert.isArray(stubbedObject.watch.args);
} catch (error) {
restore(oldWatch);
throw error;
}

restore(oldWatch);
}
});
}(this));
2 changes: 1 addition & 1 deletion test/walk-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
assert(iterator.alwaysCalledOn(rcvr));
assert(iterator.calledWith("world", "hello"));
assert(iterator.calledWith(15, "foo"));
} catch(e) {
} catch (e) {
err = e;
} finally {
Object.getOwnPropertyNames = getOwnPropertyNames;
Expand Down

0 comments on commit 9d6ae3b

Please sign in to comment.