siesta-lite
Version:
Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers
44 lines (36 loc) • 1.24 kB
JavaScript
StartTest(function (t) {
if (!('Promise' in window)) return
t.it("returning promise from test function - success", function (t) {
var resolved = false
t.testGeneric(
{ doNotTranslate : true },
function (t) {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolved = true
resolve()
}, 1000)
})
},
function (test) {
t.is(resolved, true, "Promise was resolved")
t.is(test.isPassed(), true, "Test passed correctly")
}
)
})
t.it("returning promise from test function - timeout", function (t) {
var resolved = false
t.testGeneric(
{ doNotTranslate : true },
function (t) {
t.defaultTimeout = 500
return new Promise(function (resolve, reject) {
})
},
function (test) {
t.is(resolved, false, "Promise was not resolved")
t.is(test.isPassed(), false, "Test failed correctly")
}
)
})
})