lundi 23 mars 2015

Jest - Testing Context (this)

I'd like to test if the context (this) of x is the same as the context of y. Given the following example:



var x = {
hello: function() {
return this.world;
}
}

var y = {
world: 'stackoverflow';
}

x.hello.bind(y)();


I'd expect x.hello to return stackoverflow. Is this achievable? How is this achieved?


Aucun commentaire:

Enregistrer un commentaire