Functional tests are used to mimic user events.
new MVC.Test.Controller(controller_name, tests) -> Test
Creates a new functional test case. A test case is a collection of test functions and helpers.
new MVC.Controller('todos',{
test_clicking_a_todo : function(){
this.TodoClick(2)
}
})
helpers()
Adds Controller specific helpers to Assertion Helpers.
Test.Controller dynamically creates assertion helpers based on the tested controller's actions. For example, a Test.Controller that tests a controller like:
MVC.Controller('todos', {
click : function( params ){ ... }, //matches clicks on elements with className = 'todo'
'# submit' : function(params) { ... } //matches submits on elements with id = 'todos'
})
will have helpers like TodoClick and TodosSubmit:
new MVC.Test.Controller('todos', {
test_click : function( ){
this.TodoClick(2); //clicks the 2nd element with className = 'todo'
},
'# submit' : function(params) {
this.TodosSubmit(); //submits the first element with id = 'todos'
}
})
Pretty awesome! As we can't enumerate these helpers here, they are displayed in the testing window for each test. You can click on each one to see it in action on the first matching element.
Each generated helper takes only the options_or_number parameter:
GENERATED_HELPER(options_or_number)