Created
April 6, 2011 19:24
Revisions
-
ebi created this gist
Apr 6, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ //Your example Class function Person(name) { this.name = name; } Person.prototype.greet = function () { alert(this.name); }; //The code using the class you want to test function GreetCjno() { var person = new Person('cjno'); person.greet(); } //The actual test for JST TestCase('ExampleTest', sinon.testCase({ 'test that cjno gets greeted': function () { Person = this.spy(Person); this.spy(Person.prototype, 'greet'); GreetCjno(); Person.alwaysCalledWithExactly('cjno'); assertTrue(Person.prototype.greet.calledOnce); } }));