Created
April 6, 2011 19:24
-
-
Save ebi/906335 to your computer and use it in GitHub Desktop.
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 characters
//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); | |
} | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment