You need to sign in to do that
Don't have an account?
fiona gentry
Need a test class for aura enabled class..stuck in here
Hey gurus,
stuck in here to write a test class,please suggest a test class ,below test class didn't solved the purpose
here is the aura enabled class for which test class is needed
Regards,
Fiona
stuck in here to write a test class,please suggest a test class ,below test class didn't solved the purpose
@isTest public class testStack { public static testMethod void testCallClass(){ Account acc = new Account(Name='Test Account'); insert acc; Test.startTest(); LookupSearchResult lcr = new LookupSearchResult(acc.id,'Account','Test Icon','Test Title','Test Sub-Title'); system.assert(lcr.getId() == acc.id); system.assert(lcr.getSObjectType() == 'Account'); system.assert(lcr.getIcon() == 'Test Icon'); system.assert(lcr.getTitle() == 'Test Title'); system.assert(lcr.getSubtitle() == 'Test Sub-Title'); Test.stopTest(); } }
here is the aura enabled class for which test class is needed
public class Stack { @AuraEnabled(cacheable=true) public static List<LookupSearchResult> search(String searchTerm, List<String> selectedIds){ if(String.isBlank(searchTerm) || searchTerm.length() < 2){ return null; } String t = '%' + searchTerm + '%'; // decide how you want to search, "starts with", "includes" or what List<Case_Type_Data__c> records = [SELECT Id, Name, Level_1__c, Level_2__c, Level_3__c FROM Case_Type_Data__c WHERE Level_1__c LIKE :t OR Level_2__c LIKE :t OR Level_3__c LIKE :t ORDER BY Level_1__c, Level_2__c, Level_3__c LIMIT 20]; /* You could also experiment with SOSL? records = [FIND :('*' + searchTerm + '*') IN ALL FIELDS RETURNING Case_Type_Data__c(Id, Name, Level_1__c, Level_2__c, Level_3__c)][0]; */ List<LookupSearchResult> results = new List<LookupSearchResult>(); for(Case_Type_Data__c ctd : records){ results.add(new LookupSearchResult(ctd.Id, 'Case_Type_Data__c', 'standard:case_wrap_up', ctd.Name, String.join(new List<String>{ctd.Level_1__c , ctd.Level_2__c, ctd.Level_3__c}, '; ') )); } return results; } }
Regards,
Fiona