JsUnit

## Class GLOBALS

    Object
       |
       +--GLOBALS

class GLOBALS

Method Summary
`<static> void` | `assert()` Checks that the given boolean value is true.
`<static> void` | `assertArrayEquals()` Checks that an array is equal to another by checking that both are arrays and then comparing their elements using assertObjectEquals
`<static> void` | `assertArrayEqualsIgnoringOrder()` Checks that two arrays have the same contents, ignoring the order of the contents
`<static> void` | `assertContains()` Checks that a collection contains a value by checking that collection.indexOf(value) is not -1
`<static> void` | `assertEquals()` Checks that two values are equal (using ===)
`<static> void` | `assertEqualsIgnoringOrder()` Synonym for assertArrayEqualsIgnoringOrder
`<static> void` | `assertEvaluatesToFalse()` Checks that a value evaluates to false in the sense that value == false
`<static> void` | `assertEvaluatesToTrue()` Checks that a value evaluates to true in the sense that value == true
`<static> void` | `assertFalse()` Checks that a boolean value is false.
`<static> void` | `assertHashEquals()` Checks that a hash is has the same contents as another by iterating over the expected hash and checking that each key's value is present in the actual hash and calling assertEquals on the two values, and then checking that there is no key in the actual hash that isn't present in the expected hash.
`<static> void` | `assertHTMLEquals()` Checks that a value is the same as an HTML string by "standardizing" both and comparing the result for equality.
`<static> void` | `assertNaN()` Checks that a value is NaN (Not a Number)
`<static> void` | `assertNotEquals()` Checks that two values are not equal (using !==)
`<static> void` | `assertNotNaN()` Checks that a value is not NaN (i.e.
`<static> void` | `assertNotNull()` Checks that a value is not null
`<static> void` | `assertNotUndefined()` Checks that a value is not undefined
`<static> void` | `assertNull()` Checks that a value is null
`<static> void` | `assertObjectEquals()` Checks that an object is equal to another using === for primitives and their object counterparts but also desceding into collections and calling assertObjectEquals for each element
`<static> void` | `assertRoughlyEquals()` Checks that two value are within a tolerance of one another
`<static> void` | `assertTrue()` Synonym for assertTrue
`<static> void` | `assertUndefined()` Checks that a value is undefined
`<static> void` | `clearInterval(timeoutKey)` Mocks out clearInterval by clearing Clock's scheduledFunction for the given ID
`<static> void` | `clearTimeout(timeoutKey)` Mocks out clearTimeout by clearing Clock's scheduledFunction for the given ID
`<static> Object` | `createXmlHttpRequest()` Useful for testing.
`<static> void` | `debug()`
`<static> void` | `error(errorMessage)` Causes an error
`<static> void` | `fail(failureMessage)` Causes a failure
`<static> void` | `info()`
`<static> void` | `inform()`
`<static> Object` | `isLoaded()`
`<static> Object` | `jsUnitGetParm(name)`
`<static> void` | `jsUnitSetOnLoad(windowRef, onloadHandler)`
`<static> void` | `newOnLoadEvent()`
`<static> Object` | `setInterval(funcToCall, millis)` Mocks out setInterval by registering the callback with Clock
`<static> void` | `setJsUnitTracer(aJsUnitTracer)`
`<static> Object` | `setTimeout(funcToCall, millis)` Mocks out setTimeout by registering the callback with Clock
`<static> void` | `warn()`

Method Detail

### assert

    <static> void assert()

Checks that the given boolean value is true.

Parameters:

`comment` - optional, displayed in the case of failure

Throws:

- JsUnitFailure if the given value is not true
- JsUnitInvalidAssertionArgument if the given value is not a boolean or if an incorrect number of arguments is passed

### assertArrayEquals

    <static> void assertArrayEquals()

Checks that an array is equal to another by checking that both are arrays and then comparing their elements using assertObjectEquals

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the expected array

`value` - the actual array

Throws:

- JsUnitFailure if the actual value does not equal the expected value
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertArrayEqualsIgnoringOrder

    <static> void assertArrayEqualsIgnoringOrder()

Checks that two arrays have the same contents, ignoring the order of the contents

Parameters:

`comment` - optional, displayed in the case of failure

`array1` - first array

`array2` - second array

Throws:

- JsUnitFailure if the two arrays contain different contents
- JsUnitInvalidAssertionArgument if an incorrect number of arguments are passed

### assertContains

    <static> void assertContains()

Checks that a collection contains a value by checking that collection.indexOf(value) is not -1

Parameters:

`comment` - optional, displayed in the case of failure

`collection` - the collection

`value` - the value

Throws:

- JsUnitFailure if the collection does not contain the value
- JsUnitInvalidAssertionArgument if an incorrect number of arguments are passed

### assertEquals

    <static> void assertEquals()

Checks that two values are equal (using ===)

Parameters:

`comment` - optional, displayed in the case of failure

`expected` - the expected value

`actual` - the actual value

Throws:

- JsUnitFailure if the values are not equal
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertEqualsIgnoringOrder

    <static> void assertEqualsIgnoringOrder()

Synonym for assertArrayEqualsIgnoringOrder

See:

- assertArrayEqualsIgnoringOrder()

### assertEvaluatesToFalse

    <static> void assertEvaluatesToFalse()

Checks that a value evaluates to false in the sense that value == false

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the value

Throws:

- JsUnitFailure if the actual value does not evaluate to true
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertEvaluatesToTrue

    <static> void assertEvaluatesToTrue()

Checks that a value evaluates to true in the sense that value == true

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the value

Throws:

- JsUnitFailure if the actual value does not evaluate to true
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertFalse

    <static> void assertFalse()

Checks that a boolean value is false.

Parameters:

`comment` - optional, displayed in the case of failure

Throws:

- JsUnitFailure if value is not false
- JsUnitInvalidAssertionArgument if the given value is not a boolean or if an incorrect number of arguments is passed

### assertHashEquals

    <static> void assertHashEquals()

Checks that a hash is has the same contents as another by iterating over the expected hash and checking that each key's value is present in the actual hash and calling assertEquals on the two values, and then checking that there is no key in the actual hash that isn't present in the expected hash.

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the expected hash

`value` - the actual hash

Throws:

- JsUnitFailure if the actual hash does not evaluate to true
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertHTMLEquals

    <static> void assertHTMLEquals()

Checks that a value is the same as an HTML string by "standardizing" both and comparing the result for equality. Standardizing is done by temporarily creating a DIV, setting the innerHTML of the DIV to the string, and asking for the innerHTML back.

Parameters:

`comment` - optional, displayed in the case of failure

`value1` - the expected HTML string

`value2` - the actual HTML string

Throws:

- JsUnitFailure if the standardized actual value does not equal the standardized expected value
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertNaN

    <static> void assertNaN()

Checks that a value is NaN (Not a Number)

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the value

Throws:

- JsUnitFailure if the value is a number
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertNotEquals

    <static> void assertNotEquals()

Checks that two values are not equal (using !==)

Parameters:

`comment` - optional, displayed in the case of failure

`value1` - a value

`value2` - another value

Throws:

- JsUnitFailure if the values are equal
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertNotNaN

    <static> void assertNotNaN()

Checks that a value is not NaN (i.e. is a number)

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the value

Throws:

- JsUnitFailure if the value is not a number
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertNotNull

    <static> void assertNotNull()

Checks that a value is not null

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the value

Throws:

- JsUnitFailure if the value is null
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertNotUndefined

    <static> void assertNotUndefined()

Checks that a value is not undefined

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the value

Throws:

- JsUnitFailure if the value is undefined
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertNull

    <static> void assertNull()

Checks that a value is null

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the value

Throws:

- JsUnitFailure if the value is not null
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertObjectEquals

    <static> void assertObjectEquals()

Checks that an object is equal to another using === for primitives and their object counterparts but also desceding into collections and calling assertObjectEquals for each element

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the expected value

`value` - the actual value

Throws:

- JsUnitFailure if the actual value does not equal the expected value
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertRoughlyEquals

    <static> void assertRoughlyEquals()

Checks that two value are within a tolerance of one another

Parameters:

`comment` - optional, displayed in the case of failure

`value1` - a value

`value1` - another value

`tolerance` - the tolerance

Throws:

- JsUnitFailure if the two values are not within tolerance of each other
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### assertTrue

    <static> void assertTrue()

Synonym for assertTrue

See:

- assert()

### assertUndefined

    <static> void assertUndefined()

Checks that a value is undefined

Parameters:

`comment` - optional, displayed in the case of failure

`value` - the value

Throws:

- JsUnitFailure if the value is not undefined
- JsUnitInvalidAssertionArgument if an incorrect number of arguments is passed

### clearInterval

    <static> void clearInterval(timeoutKey)

Mocks out clearInterval by clearing Clock's scheduledFunction for the given ID

### clearTimeout

    <static> void clearTimeout(timeoutKey)

Mocks out clearTimeout by clearing Clock's scheduledFunction for the given ID

### createXmlHttpRequest

    <static> Object createXmlHttpRequest()

Useful for testing. You can implement createXmlHttpRequest as a global function in your production code by returning a real request; here, when testing, it returns a MockXmlHttpRequest

### debug

    <static> void debug()

### error

    <static> void error(errorMessage)

Causes an error

Parameters:

`errorMessage` - the message for the error

### fail

    <static> void fail(failureMessage)

Causes a failure

Parameters:

`failureMessage` - the message for the failure

### info

    <static> void info()

### inform

    <static> void inform()

### isLoaded

    <static> Object isLoaded()

### jsUnitGetParm

    <static> Object jsUnitGetParm(name)

### jsUnitSetOnLoad

    <static> void jsUnitSetOnLoad(windowRef, onloadHandler)

### newOnLoadEvent

    <static> void newOnLoadEvent()

### setInterval

    <static> Object setInterval(funcToCall, millis)

Mocks out setInterval by registering the callback with Clock

Parameters:

`funcToCall` -

`millis` -

Returns:

the ID of the timeout, which is the index of the scheduledFunction in Clock's list of scheduledFunctions

### setJsUnitTracer

    <static> void setJsUnitTracer(aJsUnitTracer)

### setTimeout

    <static> Object setTimeout(funcToCall, millis)

Mocks out setTimeout by registering the callback with Clock

Parameters:

`funcToCall` -

`millis` -

Returns:

the ID of the timeout, which is the index of the scheduledFunction in Clock's list of scheduledFunctions

### warn

    <static> void warn()

JsUnit

www.jsunit.net
Documentation generated by JSDoc on Sun Sep 9 15:34:58 2007