UNPKG

siesta-lite

Version:

Stress-free JavaScript unit testing and functional testing tool, works in NodeJS and browsers

45 lines (32 loc) 1.09 kB
StartTest(function (t) { t.it("Ok assertions", function (t) { t.ok(true, 'True is ok') t.ok(1, '1 is ok') t.ok({}, '{} is ok') t.notOk(false, 'false is not ok') t.notOk(0, '0 is not ok') t.notOk(undefined, '`undefined` is not ok') }) t.it("Is assertions", function (t) { t.is(1, 1, '1 is 1') t.is(1, "1", '1 is "1"') t.is(null, undefined, 'null is undefined') t.isnt(1, 2, "1 isn't 2") }) t.it("Like assertions", function (t) { t.like('Yo', /yo/i, '"Yo" is like "yo"') t.like('Yoda', 'Yo', '"Yoda" contains "Yo"') }) t.it("Throws / lives assertions", function (t) { t.throwsOk(function () { throw "yo" }, /yo/, 'Exception thrown, and its "yo"') t.livesOk(function () { var a = 1 }, 'Exception not thrown') }) t.it("Deep comparison", function (t) { t.isDeeply({ a : 1, b : 2 }, { a : '1', b : 2 }, 'Correct') t.isDeeply({ a : 1, b : 2 }, { a : 1, b : 2 }, 'Correct') }) })