CBWIRE
InstallSource CodeIssuesSupport
v2.x
v2.x
  • Introduction
  • Release History
    • What's New With 2.2
    • What's New With 2.1
    • What's New With 2.0
  • Getting Started
  • Examples
  • Essentials
    • Configuration
    • Wires
    • Data Properties
    • Computed Properties
      • Computed Properties ( Proxied )
    • Actions
    • Templates
    • Events & Listeners
    • Wire Lifecycle
    • JavaScript
    • Testing
  • Wire Features
    • Validation
    • File Uploads
    • Query String
    • Redirecting
    • Dependency Injection
  • Template Features
    • Directives
    • Loading States
    • Polling
    • Prefetching
    • Offline State
    • Defer Loading
    • Dirty State
  • Integrations
    • ContentBox CMS
    • Turbo
    • AlpineJS
    • Inline Scripts
Powered by GitBook
On this page
  • Test Example
  • Test Methods
  • data
  • computed
  • toggle
  • call
  • emit
  • see
  • dontSee
  • seeData
  • dontSeeData

Was this helpful?

Export as PDF
  1. Essentials

Testing

Front-end testing of your UI Wires using a beautiful test API.

PreviousJavaScriptNextValidation

Last updated 2 years ago

Was this helpful?

You can easily test your by extending cbwire.models.BaseWireTest and using our fluent testing API in your specs.

Test Example

You can invoke your for testing by using wire().

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>" );
		} );
	
	} );
    }
}

Test Methods

data

wire( "TaskList" )
    .data( "tasks", [ "task1", "task2" ] ) // one property at a time
    .data( { "tasks" : [ "task1", "task2" ] } ); // struct of properties

computed

wire( "TaskList" )
    .computed( "count", function() { return 3; } ) // one property at a time
    .computed( { "count" : function() { return 3; } } ); // struct of properties

toggle

wire( "TaskList" ).toggle( "showModal" );

call

wire( "TaskList" ).call( "clearTasks" );
wire( "TaskList" ).call( "clearTasks", [ param1, param2 ] );

emit

wire( "TaskList" ).emit( "addedTask" );
wire( "TaskList" ).emit( "addedTask", [ param1, param2 ] );

see

wire( "TaskList" ).see( "<h1>My Tasks</h1>" );

dontSee

wire( "TaskList" ).dontSee( "<h1>Someone Else's Tasks</h1> ");

seeData

wire( "TaskList" ).seeData( "tasksRemoved", true );

dontSeeData

wire( "TaskList" ).dontSeeData( "tasksRemoved", true );

Set a to the specified value.

Set a to the specified closure.

Toggles a between true and false.

Calls an . Optional array of parameters can be provided.

Emits an and fires any that are defined on the . Optional array of parameters can be provided, which will be passed on to listeners.

Verifies a value can be found in the current rendering. Otherwise, test fails.

Verifies a value is not found in the current rendering. Otherwise, test fails.

Verifies a matches a specified value. Otherwise, test fails.

Verifies a does not match a specified value. Otherwise, test fails.

Wires
TestBox
Wires
Data Property
Computed Property
Data Property
Action
Template
Template
Data Property
Data Property
Event
Wire
Listeners