must
Version:
Testing and assertion library with friendly BDD syntax — awesome.must.be.true(). Many expressive matchers and is test runner and framework agnostic. Follows RFC 2119 with its use of MUST. Good and well tested stuff.
43 lines (35 loc) • 1.33 kB
JavaScript
var Must = require("../..")
var assert = require("./assert")
describe("Must.prototype.startWith", function() {
describe("given string", function() {
it("must pass if string starts with given shorter string", function() {
assert.pass(function() { Must("Hello, John").startWith("Hello") })
})
it("must fail if string does not start with given shorter string",
function() {
assert.fail(function() { Must("Hello, John").startWith("Bye") })
})
it("must fail if string ends with given shorter string", function() {
assert.fail(function() { Must("Hello, John").startWith("John") })
})
it("must fail if string contains given string", function() {
assert.fail(function() { Must("Hello").startWith("l") })
})
it("must fail given a longer string", function() {
assert.fail(function() { Must("Hello").startWith("John, Hello") })
assert.fail(function() { Must("Hello").startWith("Hello, John") })
})
})
require("./_assertion_error_test")(function() {
Must("Hello").startWith("Bye")
}, {
actual: "Hello",
expected: "Bye",
message: "\"Hello\" must start with \"Bye\""
})
describe(".not", function() {
it("must invert the assertion", function() {
assert.fail(function() { Must("Hello").not.startWith("He") })
})
})
})