You need to sign in to do that
Don't have an account?

Writing Test Class for my search lightning component
I have been attempting to write a test class for my search function but its throwing me a little, my first time designing a lightning component so if someone could walk me through it that would I would hugely appreciate it.
ContactList.cmp
ControllerListController.js
ContactListController.apxc
SearchBar.cmp
SearchBarController.js
ContactList.cmp
<aura:component controller="ContactListController"> <aura:attribute name="accounts" type="account[]"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}" /> <aura:handler event="c:SearchKeyChange" action="{!c.searchKeyChange}"/> <ul> <aura:iteration items="{!v.accounts}" var="account"> <li> <a href="{! '#/sObject/' + account.Id + '/view'}"> <p>{!account.Name}</p> <p>{!account.Phone}</p> <p>{!account.BillingStreet}</p> </a> </li> </aura:iteration> </ul> </aura:component>
ControllerListController.js
({ doInit : function(component, event) { var action = component.get("c.findAll"); action.setCallback(this, function(a) { component.set("v.accounts", a.getReturnValue()); }); $A.enqueueAction(action); }, searchKeyChange: function(component, event) { var searchKey = event.getParam("searchKey"); var action = component.get("c.findByLocation"); action.setParams({ "searchKey": searchKey }); action.setCallback(this, function(a) { component.set("v.accounts", a.getReturnValue()); }); $A.enqueueAction(action); } })
ContactListController.apxc
public with sharing class ContactListController { @AuraEnabled public static List<Account> findAll() { return [SELECT id, name, BillingStreet, phone FROM Account LIMIT 50]; } @AuraEnabled public static List<Account> findByLocation(String searchKey) { String name = '%' + searchKey + '%'; return [SELECT id, name, phone, BillingStreet FROM Account WHERE BillingStreet LIKE :name LIMIT 50]; } }
SearchBar.cmp
<aura:component > <div> <input type="text" class="form-control" placeholder="Search" onkeyup="{!c.searchKeyChange}"/> </div> </aura:component>
SearchBarController.js
({ searchKeyChange : function(component, event, helper) { var myEvent = $A.get("e.c:SearchKeyChange"); myEvent.setParams({"searchKey":event.target.value}); myEvent.fire(); } })
I am trying to save the code then it is showing this error message. how u done this ? Failed to save undefined: No EVENT named markup://c:searchKeyChange1 found : [markup://c:ContactList]: Source