Skip to content

Instantly share code, notes, and snippets.

@lightsofapollo
Created May 15, 2012 17:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lightsofapollo/2703499 to your computer and use it in GitHub Desktop.
Example Test
var Example = (function(){
return {
math: function() {
},
complexMethod: function() {
}
}
}());
requireApp('example/js/example.js');
suite('Example', function() {
var subject;
//will be called before each "test" block.
setup(function() {
subject = new Example();
});
//for a simple method
test('#math', function() {
var result = subject.math('1', '+', '1');
assert.equal(result, 2, 'addition should work');
});
//when you have a method that will
//require complex setup/teardown logic
suite('#complexMethod', function() {
var result;
setup(function() {
//complex setup stuff
result = subject.complexMethod();
});
test('stuff works', function() {
assert.equal(result, 'real value', 'should output real value');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment