initial commit (work in progress)

This commit is contained in:
Leo Horie 2016-04-20 20:02:37 -04:00
parent 13fdb60f66
commit 559369016d
83 changed files with 10461 additions and 0 deletions

94
ospec/tests/test-ospec.js Normal file
View file

@ -0,0 +1,94 @@
"use strict"
var callAsync = require("../../test-utils/callAsync")
var o = require("../ospec")
new function(o) {
o = o.new()
o.spec("ospec", function() {
o("skipped", function() {
o(1).equals(1)
})
o.only(".only()", function() {
o(2).equals(2)
})
})
o.run()
}(o)
o.spec("ospec", function() {
o.spec("sync", function() {
var a = 0, b = 0
o.before(function test() {a = 1})
o.after(function test() {a = 0})
o.beforeEach(function test() {b = 1})
o.afterEach(function test() {b = 0})
o("assertions", function test() {
var spy = o.spy()
spy(a)
o(a).equals(b)
o(a).notEquals(2)
o({a: [1, 2], b: 3}).deepEquals({a: [1, 2], b: 3})
o([{a: 1, b: 2}, {c: 3}]).deepEquals([{a: 1, b: 2}, {c: 3}])
var values = ["a", "", 1, 0, true, false, null, undefined, Date(0), ["a"], [], function() {return arguments}.call(), new Uint8Array(), {a: 1}, {}]
for (var i = 0; i < values.length; i++) {
for (var j = 0; j < values.length; j++) {
if (i === j) o(values[i]).deepEquals(values[j])
else o(values[i]).notDeepEquals(values[j])
}
}
o(spy.callCount).equals(1)
o(spy.args.length).equals(1)
o(spy.args[0]).equals(1)
})
})
o.spec("async", function() {
var a = 0, b = 0
o.before(function test(done) {
callAsync(function() {
a = 1
done()
})
})
o.after(function test(done) {
callAsync(function() {
a = 0
done()
})
})
o.beforeEach(function test(done) {
callAsync(function() {
b = 1
done()
})
})
o.afterEach(function test(done) {
callAsync(function() {
b = 0
done()
})
})
o("async hooks", function test(done) {
callAsync(function() {
var spy = o.spy()
spy(a)
o(a).equals(b)
o(a).equals(1)("a and b should be initialized")
done()
})
})
})
})