Test.Unit.Assertions
Signature
Methods:
initialize: function()
constructor
summary: function(): String
Returns a concatenated string which represents the assertions, errors, failures, and messages properties.
pass: function()
This code increases the number of assertions without risking a failure or error
fail: function( message (converted to string) )
Adds a failure message to messages property and increments failures property
info: function( message (converted to string) )
Adds an info message to messages property
error: function(error:Error)
Adds an error message to messages property and increments error property
status: function()
Returns ‘failed’, ‘error’, or ‘passed’ based on the error and failure count. If there are errors and failures, only ‘failure’ will be returned..
assertElementsMatch: function( ...args )
Do all objects in the arguments array match the first item in that array? ie: Does assertElementsMatch([‘a’,‘b’,‘c’], ‘a’, ‘b’, ‘c’ ) should be true?
assertElementMatches: function(element, expression)
assertElementsMatch([element], expression)
benchmark: function(operation: Function, iterations: Number = 1):Number
Calls operation iteration number of times and returns how long it took to call all of them.
-———————————————————————————————————————————————————————————-
NOTE: In all of the below functions, there is a third parameter message:String
. If this is used, then that message will be appended to the string sent into the fail function in case the assertion does not succeed.
-———————————————————————————————————————————————————————————-
assert: function(expression)
If expression evaluates to true, this will call pass(), otherwise it will call fail()
assertInspect: function(expected:Object, actual:Object)
Does expected == actual.inspect()
assertEnumEqual: function(expected:Object, actual:Object)
Goes through two dynamic objects and compares them point for point
assertRespondsTo: function(method:String, obj:Object)
Does obj have a method by the name given?
assertRaise: function(exceptionName:String, method:Function)
Does this method raise the error of the correct exceptionName?
assertHidden: function(element)
Shortcut for assertEqual(“none”, element.style.display)
assertMatch: function(expression:String (regular expression), actual:String)
Does the string match the regular expressions?
The next series of functions come in pairs, those which include the word “Not” means that the
assertEqual: function(expected, actual)
Does expected == actual?
assertNotEqual: function(expected, actual)
assertIdentical: function(expected, actual)
Does expected = actual?
assertNotIdentical: function(expected, actual)
assertNull: function(obj)
Does obj = null
assertNotNull: function(object)
assertType: function(expected:Class, actual:Object)
Is the actual item a member of the expected Class (does not work on descendant classes)
assertNotOfType: function(expected:Class, actual:Object)
assertInstanceOf: function(expected:Class, actual:Object)
Is the actual item an instance of the expected Class or its descendants
assertNotInstanceOf: function(expected, actual)
assertReturnsTrue: function(method, obj)
Does the function return true?
assertReturnsFalse: function(method, obj)
assertVisible: function(element:Element)
_isVisible
will return true for element
assertNotVisible: function(element)
<!— Private!
_isVisible: function(element)
Returns whether an element is visible. It calls itself recursively until it gets to the document root.
—>
Properties
assertions: Number
failures: Number
errors: Number
messages: Array( Strings )