Comment on page
Testing
Test your components using TestBox.
CBWIRE includes a beautiful test API to test your front-end components quickly.
To start, make sure you extend BaseWireTest in your test spec.
You can invoke your component by calling wire() and then chain additional state changes and assertions.
component extends="cbwire.models.BaseWireTest" {
function run(){
describe( "TaskList.cfc", function(){
it( "calling 'clearTasks' removes the tasks", function() {
wire( "TaskList" )
// Sets our data properties
.data( "tasks", [ "task1" ] )
// Verifies output in our template rendering
.see( "<li>task 1</li>" )
// Runs the 'clearTasks' action
.call( "clearTasks" )
// Verifies updated template rendering
.dontSee( "<li>task 1</li>" );
} );
} );
}
}
Set a data property to the specified value.
wire( "TaskList" )
.data( "tasks", [ "task1", "task2" ] ) // one property at a time
.data( { "tasks" : [ "task1", "task2" ] } ); // struct of properties
Set a computed property to the specified closure.
wire( "TaskList" )
.computed( "count", function() { return 3; } ) // one property at a time
.computed( { "count" : function() { return 3; } } ); // struct of properties
Toggles a data property between true and false.
wire( "TaskList" ).toggle( "showModal" );
Calls an action. An optional array of parameters can be provided.
wire( "TaskList" ).call( "clearTasks" );
wire( "TaskList" ).call( "clearTasks", [ param1, param2 ] );
Emits an event and fires any listeners that are defined on the component. An optional array of parameters can be provided, which will be passed on to listeners.
wire( "TaskList" ).emit( "addedTask" );
wire( "TaskList" ).emit( "addedTask", [ param1, param2 ] );
Verifies a value can be found in the current component rendering. Otherwise, the test fails.
wire( "TaskList" ).see( "<h1>My Tasks</h1>" );
Verifies a value is not found in the current component rendering. Otherwise, the test fails.
wire( "TaskList" ).dontSee( "<h1>Someone Else's Tasks</h1> ");
Verifies a data property matches a specified value. Otherwise, the test fails.
wire( "TaskList" ).seeData( "tasksRemoved", true );
Verifies a data property does not match a specified value. Otherwise, test fails.
wire( "TaskList" ).dontSeeData( "tasksRemoved", true );
Last modified 2mo ago