-
Notifications
You must be signed in to change notification settings - Fork 1
CbC test helpers
knutkj edited this page Oct 7, 2012
·
3 revisions
If you do JavaScript TDD or unit testing it may be a pain to test that assertions have been applied correctly. For convenience some test helpers have been implemented. Here is a sample on how to use the verifyAssertions
test helper to simplify assertion testing using the QUnit testing framework:
test("funcToVerify: verify assertions applied correctly", function () {
// Arrange.
var funcToVerify = namespace.prototype.funcToVerify;
var paramDefs = [
{
paramName: "stringParam",
validValue: "valid value",
assertions: [ "defined", "notNull", "string", "notEmpty" ]
},
{
paramName: "numberParam",
validValue: 1,
assertions: [ "defined", "notNull", "number" ]
}
];
// Act and assert.
cbc.testhelpers.verifyAssertions(funcToVerify, paramDefs);
});