Test helper that inspects the ws test log. Returns true iff a recorded wsPublish matched the given channel (and the given event when one is provided). When the optional predicate is a closure, it is called with the recorded data payload and the assertion is true only if the closure returns true. This lets the CFML test suite assert on realtime broadcasts with no live WebSocket client attached.
assertBroadcast( channel [, event [, predicate]] )
→ returns boolean
After wsPublish records a broadcast, assertBroadcast confirms it.
wsPublish( channel="/chat", event="message", data={ text="hi" } );
assertBroadcast( "/chat", "message" ); // true
assertBroadcast( "/chat", "nope" ); // false
Expected Result: true / false
Pass a closure to check the recorded data payload.
assertBroadcast( "/chat", "message", function( d ){ return d.text == "hi"; } ); // true
assertBroadcast( "/chat", "message", function( d ){ return d.text == "bye"; } ); // false
Expected Result: true / false
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.