I'm trying to spy window.document with sinon.js. What I do is this:
var document = {
getElementById = function() {}
}
sinon.spy(document, "getElementById").withArgs("foo").returnValues = ["bar"];
What I expect from this call is this: When document.getElementById is called with the argument "foo" the function must return "bar". What's my error?
If I define getElementById by myself like this I get the expected result:
document.getElementById = function(param) {
if (param === "foo") return "bar";
}