public
Created

Example Test

  • Download Gist
example.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11
var Example = (function(){
return {
math: function() {
},
complexMethod: function() {
}
}
}());
example_test.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
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');
});
});
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.