Skip to content

Instantly share code, notes, and snippets.

@erkantaylan
Forked from sajirdalas/Tutorial 9
Last active August 29, 2015 14:20
Show Gist options
  • Save erkantaylan/043763ba41c6062424f3 to your computer and use it in GitHub Desktop.
Save erkantaylan/043763ba41c6062424f3 to your computer and use it in GitHub Desktop.
//silly.js
function sumNumbers(a, b){
return a+b;
}
function sumNumbersAsync(a, b, callback){
var result = a + b;
callback(result);
}
exports.sumNumbers = sumNumbers;
exports.sumNumbersAsync = sumNumbersAsync;
//test-main.js
var silly = require("./silly");
exports["test main"] = function(assert) {
var result = silly.sumNumbers(1,2);
assert.pass(result == 3, "Unit test running!");
assert.equal(result, 3, "Second unit test running!");
assert.notEqual(result, 4, "Third unit test running!");
};
exports["test main async"] = function(assert, done) {
silly.sumNumbersAsync(1, 2, function(result){
assert.pass(result == 3, "Unit test running! ASYNC");
assert.equal(result, 3, "Second unit test running! ASYNC");
assert.notEqual(result, 3, "Third unit test running! ASYNC");
done();
})
};
require("sdk/test").run(exports);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment