Validating that the selected drivers are sent to the server

In this test, we are focused on validating the fact that whatever the user selected from the data table is processed correctly and results in an expected JSON request to the Apex Controller. Of course, the real Apex Controller code is not actually invoked; its mock is!

In this case, the code uses the ability of the Jest framework to record interactions with the mock object it creates and later allows test code to assert that expected parameters were passed. We will also be asserting that toast and custom events got sent by the code. 

As a reminder, here is a shortened version of the Race Setup controller code this test will be testing. For the full version, review the raceSetup.js ...

Get Salesforce Lightning Platform Enterprise Architecture - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.