Fork me on GitHub

Module ringo/unittest

Functions

Class jsDump

Static Methods


assertEqual (val1, val2)

Checks if the values passed as arguments are equal.

Parameters

Object val1 The value that should be compared to the second argument.
Object val2 The value that should be compared to the first argument.

Throws

ArgumentsException, AssertionException

assertFalse (val)

Checks if the value passed as argument is boolean false.

Parameters

Object val The value that should be boolean false.

Throws

ArgumentsException, AssertionException

assertMatch (val, rxp)

Checks if the regular expression matches the string.

Parameters

String val The string that should contain the regular expression pattern
RegExp rxp The regular expression that should match the value

Throws

ArgumentsException, AssertionException

assertNaN (val)

Checks if the value passed as argument is NaN.

Parameters

Object val The value that should be NaN.

Throws

ArgumentsException, AssertionException

assertNotEqual (val1, val2)

Checks if the values passed as arguments are not equal.

Parameters

Object val1 The value that should be compared to the second argument.
Object val2 The value that should be compared to the first argument.

Throws

ArgumentsException, AssertionException

assertNotNaN (val)

Checks if the value passed as argument is not NaN.

Parameters

Object val The value that should be not NaN.

Throws

ArgumentsException, AssertionException

assertNotNull (val)

Checks if the value passed as argument is not null.

Parameters

Object val The value that should be not null.

Throws

ArgumentsException, AssertionException

assertNotUndefined (val)

Checks if the value passed as argument is not undefined.

Parameters

Object val The value that should be not undefined.

Throws

ArgumentsException, AssertionException

assertNull (val)

Checks if the value passed as argument is null.

Parameters

Object val The value that should be null.

Throws

ArgumentsException, AssertionException

assertStringContains (val, str)

Checks if the value passed as argument contains the pattern specified.

Parameters

String val The string that should contain the pattern
String str The string that should be contained

Throws

ArgumentsException, AssertionException

assertThrows (func, exception)

Checks if the function passed as argument throws a defined exception.

Parameters

Object func The function to call
Object exception Optional object expected to be thrown when executing the function

Throws

ArgumentsException, AssertionException

assertTrue (val)

Checks if the value passed as argument is boolean true.

Parameters

Object val The value that should be boolean true.

Throws

ArgumentsException, AssertionException

assertUndefined (val)

Checks if the value passed as argument is undefined.

Parameters

Object val The value that should be undefined.

Throws

ArgumentsException, AssertionException

jsDump (value, lvl)

Converts the value passed as argument into a nicely formatted and indented string

Parameters

Object value The value to convert into a string
Number lvl Optional indentation level (defaults to zero)

Returns

String The string representation of the object passed as argument

jsDump.indent (lvl)

Parameters

lvl

jsDump.quote (str)

Parameters

str

run (modulePathOrScope, writer)

The main runner method

Parameters

String|Object modulePathOrScope Either the path to a module containing unit tests to execute, or an object containing the exported test methods or nested scopes.
Object writer Optional writer to use for displaying the test results. Defaults to TermWriter.