- Copyright:
- (c) Copyright 2013 - 2016 AV Digital Media Ltd. All Rights Reserved. No unauthorized copying, distribution or modification to this code in whole or in part is permitted without the express permission of AV Digital Media Ltd (UK).
Properties:
Name | Type | Description |
---|---|---|
AUTO_RUN |
Boolean | Auto run the unit test cycle |
SUPPRESS_ALERT |
Boolean | Set the debugger to supress alert dialogs if run in a browser without a log console |
TEST_SPEED |
Number | The speed in milliseconds |
OUTPUT_TYPE |
Number | Defines the output type for AIMUNIT, 1(Log Only), 2(Dom Only), 3(Both) |
USE_GLOBAL_REFERENCE |
Boolean | Determines whether the methods should be bound to the global namespace |
INJECTABLES |
Array | Injectables - the methods that can be injected into the test cycle |
DEFUALT_PANEL_OPEN |
Boolean | Default open state for the panel |
PRESERVE_CYCLE |
Boolean | Preserve the test cycle, do not output the results and wait for new tests to be injected into the framework |
POSITION |
Number | The default position index |
POSITIONS |
Array | Position array list |
CURRENTQUEUE_INDEX |
Number | Current Queue Index |
NO_ERROR_CATCHING |
Boolean | Defined if any errors should be caught |
HIDE_PASSED_ITEMS |
Boolean | Determines whether the successful tests should be hidden |
MONITOR_ACTIVE |
Boolean | Determines whether AIM Unit should monitor the loaded JavaScript and CSS files for change |
APPLICATION_PATH |
String | Testing application path, the application that should be tested, this is only required if the iframe content holder is to be used |
APPLICATION_NAMESPACE |
String | The application namespace, if applicable, perhaps the app uses a functional approach and the user decided to pollute the global namespace |
CAPTURE_MOUSE |
Boolean | Capture the mouse position at the point of execution for the test |
PRINT_SCREEN_DETAILS |
Boolean | Logs the screen details with the test results |
ABORT_ON_ERROR |
Boolean | Halt the test cycle on errors |
REFRESH_SCREEN_DIMS |
Boolean | Determines whether the screen dimensions should be refreshed on browser resize |
PRINT_SCREENSHOT |
Boolean | Determines whether to grap a screen capture |
SESSION_NAME |
String | Optional session name to be appended to the prints |
PRINT_COUNT |
String | Current printed item count |
The aim.unit application testing facility for reflective and standard unit testing of the JavaScript code base
Methods
(private, static) addClass(node, value)
Add a class to an element
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | The HTML Element |
value |
String | The selector names to set |
(private, static) addEvents()
Add the click events to the panel buttons and other elements
(private, static) addInjectables()
Adds the injectable classes if specified to the injection list
(static) addToDom(item, description)
Check an element exists in the dom under the specified parent
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to find in the dom |
description |
String | The parent element to start the parse for |
(static) arrayContains(item, value, description)
TODO Check if an array contains a specific value/object at the designated index or if no index is supplied any index
Parameters:
Name | Type | Description |
---|---|---|
item |
Array | The array to check |
value |
* | The value to check against, this is a wildcard |
description |
String | The description for the test |
(static) assert(valueResult, description)
Make an assertion
Parameters:
Name | Type | Description |
---|---|---|
valueResult |
function | The function for the assertion |
description |
String | The output description for the test |
(private, static) attr(node, name, value)
Set or Get an attribute value for an element
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | The HTML Element |
name |
String | The name of the attribute |
value |
String | Optional value for the attribute |
(static) ayncAssert()
TODO An aync assertion type
(private, static) checkGlobals()
Set up global references to the unit test methods, these are for quick access to the methods without the need to call via the AIMJS.Unit namespace
(private, static) checkResults(result, description)
Checks the results of a specific test and determines if the test succeeded or failed
Parameters:
Name | Type | Description |
---|---|---|
result |
Boolean | The boolean result for the tested item |
description |
String | The test item description |
(static) childCount(item, child, description)
TODO Determines whether a HTML Element has a specific child count i.e. a select element has 10 option children
Parameters:
Name | Type | Description |
---|---|---|
item |
HTMLElement | The element to check |
child |
String | The node type to check against |
description |
String | The description for the test |
(private, static) createDomOutput(type, title, content, notes, parent)
Creates an output object to be appended to the DOM
Parameters:
Name | Type | Description |
---|---|---|
type |
String | The type of output, Heading, HeadingTest |
title |
String | The title of the test |
content |
String | The main message for the test |
notes |
String | The supplementary notes and output test for the test |
parent |
Object | The parent id that this content should be appended to |
(private, static) createLogOutput(type, title, content, notes)
Create an ouput object that is logged to the console
Parameters:
Name | Type | Description |
---|---|---|
type |
String | The type of output, Heading, HeadingTest |
title |
String | The title of the test |
content |
String | The main message for the test |
notes |
String | The supplementary notes and output test for the test |
(private, static) createOutput(type, title, content, notes, parent)
Creates the output object and appends to either the dom, the console or both
Parameters:
Name | Type | Description |
---|---|---|
type |
String | The type of output, Heading, HeadingTest |
title |
String | The title of the test |
content |
String | The main message for the test |
notes |
String | The supplementary notes and output test for the test |
parent |
Object | The parent id that this content should be appended to |
(static) customAssertion(name, func, bind, scope)
Inject custom assertion method and bind it to the AIM Unit object so that it can be used
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the custom asserter |
func |
function | The callback function to execute |
bind |
Boolean | The boolean defining whether the result should be bound |
scope |
Object | The scope to execute the callback function |
(private, static) end()
End the test cycle, stop waiting and set the run Cycle to false
(private, static) executeTestGroup()
Executes the test for a specific test group
(private, static) getElement(item)
Get an element from the dom, this is not a test simple a utility function
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to find in the dom |
(private, static) getElementText(item)
Get an elements text value from the dom, this is not a test simple a utility function
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to find in the dom |
(private, static) getMouseXY()
Get the current mouse position, this action is recorded for Capturing the user behaviour
(private, static) getNotes(result, successMessage, failedMessage, optionalSuccessMessage, optionalFailedMessage)
Simple check to determine which response note to used, common function to all assertions
Parameters:
Name | Type | Description |
---|---|---|
result |
Boolean | The assertion result, true/false - success/fail |
successMessage |
Boolean | The success message to use |
failedMessage |
Boolean | The failed message to use |
optionalSuccessMessage |
Boolean | The additional success message to use |
optionalFailedMessage |
Boolean | The additional failed message to use |
(private, static) getTimer(isTest)
Gets the current time and subtracts the start time to determine how long the method took to execute
Parameters:
Name | Type | Description |
---|---|---|
isTest |
Boolean | Defines if its the global test timer |
(private, static) getWindowDims()
Gets the current window dimensions and stores the results for display
(private, static) handleAddInjection()
Event handler for the inject button in the injection panel
(private, static) handleCheckboxClick()
Handle the toggle of the open/close action
(private, static) handleCloseInjector()
Handle close the injection panel
(private, static) handleEndCycle()
Handles forcing the end to the unit test cycle
(private, static) handleInputClick()
Handle close the injection panel
(private, static) handleOpenClose()
Handle the toggle of the open/close action
(private, static) handleOpenInjector()
Handle open the injection panel
(private, static) handlePositionChange()
Handle the toggle of the starting and stopping of the test cycle
(private, static) handleRefresh()
Restarts the test cycle this will rerun all tests, dynamically injected are also preserved in the queue.
(private, static) handleResize()
Handler the resize event and capture the new window dimensions
(private, static) handleRunCycle()
Handles forcing the end to the unit test cycle
(private, static) handleStartStop()
Handle the toggle of the starting and stopping of the test cycle
(private, static) handleToggleSettings()
Handle toggling the state of the settings panel
(static) hasAttr(item, className, description)
Determines if a specified element has a specific attribute
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to check on the dom |
className |
String | The attribute name to check |
description |
String | The description for the test |
(private, static) hasClass(node, value)
Check if an element has a class assigned
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | The HTML Element |
value |
String | The class name to search for |
(static) hasClass(item, className, description)
Determines if a specified element has a specific class
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to check on the dom |
className |
String | The class name to check |
description |
String | The description for the test |
(static) hasEvent(item, evntName, description)
Determines if a specified element does has the event
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to check on the dom |
evntName |
String | The event name to check |
description |
String | The description for the test |
(static) hasFunction(item, property, description)
hasfunction assertion determines if the passed value has a specified function
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
property |
String | The prototype property name to check for |
description |
String | The output description for the test |
(static) hasInheritProperty(item, property, description)
Check if an object has an inherited property
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
property |
String | The property name to check for |
description |
String | The output description for the test |
(static) hasNotAttr(item, className, description)
Determines if a specified element does not have attribute
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to check on the dom |
className |
String | The attribute name to check |
description |
String | The description for the test |
(static) hasNotClass(item, className, description)
Determines if a specified element does not have a specific class
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to check on the dom |
className |
String | The class name to check |
description |
String | The description for the test |
(static) hasNotEvent(item, evntName, description)
Confirms that specified element does not have an event binding of the given type
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to check on the dom |
evntName |
String | The event name to check |
description |
String | The description for the test |
(static) hasNotFunction(item, property, description)
hasnotfunction assertion determines if the passed value has not a specified function
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
property |
String | The prototype property name to check for |
description |
String | The output description for the test |
(static) hasNotInheritProperty(item, property, description)
Checks that an object does not have a property
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
property |
String | The property name to check for |
description |
String | The output description for the test |
(static) hasNotProperty(item, property, description)
Checks that an object does not have a property
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
property |
String | The property name to check for |
description |
String | The output description for the test |
(static) hasProperty(item, property, description)
Check has property
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
property |
String | The property name to check for |
description |
String | The output description for the test |
(private, static) initApplication(message)
Shows the message panel to the user and sets a timeout
Parameters:
Name | Type | Description |
---|---|---|
message |
String | The message string to display in the panel |
(private, static) initialize()
Initialise the object and set the default properties
(static) inject(method, execute)
Inject a group of tests into the test cycle
Parameters:
Name | Type | Description |
---|---|---|
method |
String | The function name of the test group initializer |
execute |
Boolean | Automatically execute the test runner |
(private, static) insertDomHTML()
Inserts the AIM.Unit Markup into the application dom
(static) isArray(item, description)
Check is array
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
description |
String | The output description for the test |
(static) isDate(item, description)
TODO Check if the passed object is a date object
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The object to make the comparison against |
description |
String | The description for the test |
(static) isFunc(item, description)
Check is function
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
description |
String | The output description for the test |
(static) isInstanceOf(item, instance, description)
Check is instanceof
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
instance |
Object | The Instance type to check |
description |
String | The output description for the test |
(static) isNull(item, description)
Check is null
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
description |
String | The output description for the test |
(static) isNumber(item, description)
Check is number
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
description |
String | The output description for the test |
(static) isString(item, description)
Check is string
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
description |
String | The output description for the test |
(static) isUndefined(item, description)
Check is undefined
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
description |
String | The output description for the test |
(private, static) log()
Send to the console, this method has been stripped from the AIM Logger to ensure
(private, static) monitor()
TODO Run time file monitoring for script changes, it will work for all CSS and JavaScript files, discussion underway as to whether this should include the application files that are being tested given the iframe loading, this could be potentially a security risk
(static) notNull(item, description)
Check is not null
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
description |
String | The output description for the test |
(static) notUndefined(item, description)
Check is not undefined
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
description |
String | The output description for the test |
(private, static) objectType(obj, addString)
Returns the object type of the object passed
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | The object to test which could be a number, string, function, array etc |
addString |
String | The object type string to check against |
(static) objType(item, type, description)
Check object type of the object passed, matches the type expected
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
type |
String | String type of the object to compare against |
description |
String | The output description for the test |
(static) optionsMatch(item, array, description)
Determines if a select element has the options listed in the order supplied
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to check on the dom |
array |
String | The array to compare the option list against |
description |
String | The description for the test |
(private, static) parseError(error)
Parse the Error message and the stack to a readable formate
Parameters:
Name | Type | Description |
---|---|---|
error |
Error | The error message to parse |
(static) pauseTests()
Pause the test cycle
(private, static) propertyExists(item, property, type)
Check if a specific property exists, and of the type specified
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The object to check the property existence against |
property |
String | The name of the property to check |
type |
String | The Expected type, either Number, String, Array, Function, Object, Boolean and other valid types |
(static) propertyLength(item, property, description)
Check the property length matches the expected value
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The item to test |
property |
String | The property name to check for |
description |
String | The output description for the test |
(static) ready()
Ready state for the AIM.Unit initialization, this should be called when all customization properties have been set by the user
(private, static) removeClass(node, value)
Remove a class from an element
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | The HTML Element |
value |
String | The selector names to remove |
(static) runTests()
Run the unit tests cycle
(private, static) saveScreen()
Save the specified screen to the server
(private, static) scrolllDisplay()
Scroll the display to the bottom each time dom elements are inserted during the test cycle
(private, static) setReferences()
Get the element reference for the aim.unit browser display panel
(private, static) showMessage(message)
Shows the message panel to the user and sets a timeout
Parameters:
Name | Type | Description |
---|---|---|
message |
String | The message string to display in the panel |
(private, static) startTimer(isTest)
Starts a new test timer
Parameters:
Name | Type | Description |
---|---|---|
isTest |
Boolean | Defines if its the global test timer |
(static) strictEqual(itemA, itemB, description)
Check strict equal
Parameters:
Name | Type | Description |
---|---|---|
itemA |
Object | The first item to compare |
itemB |
Object | The second item to compare |
description |
String | The output description for the test |
(static) strictNotEqual(itemA, itemB, description)
Check strict not equal
Parameters:
Name | Type | Description |
---|---|---|
itemA |
Object | The first item to compare |
itemB |
Object | The second item to compare |
description |
String | The output description for the test |
(static) test(testName, testFunc, skip)
The main test method, called to create a new test group which can contain 1 or many assertions and tests
Parameters:
Name | Type | Description |
---|---|---|
testName |
String | The name of the test |
testFunc |
function | The function to call for the test |
skip |
Boolean | Defines whether the test should be skipped |
(static) throwsError(item, errorType, description)
TODO Check if a call throws a specific errors as expected
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | The object to catch the error from |
errorType |
Error | The error type to check against |
description |
String | The description for the test |
(private, static) updatePosition(item)
Updates the panel position
Parameters:
Name | Type | Description |
---|---|---|
item |
String | The item to find in the dom |
(static) updatePosition(position)
Public API method for updating the applications position in the display
Parameters:
Name | Type | Description |
---|---|---|
position |
String | The position of the aim.unit panel to set |
(private, static) waiting()
Outputs the waiting status for the test Cycle