I have EditorModalController.searchDoctors
that returns a list of contacts.
public class EditorModalController {
@AuraEnabled
public static List<Contact> searchDoctors(String searchValue) {
String s = '*' + searchValue + '*';
String doctorRecordTypeId = Schema.Sobjecttype.Contact.getRecordTypeInfosByName().get('Doctor').getRecordTypeId();
List<List<SObject>> searchList = [FIND :s IN ALL Fields
RETURNING Contact (Id, FirstName, LastName, NPI__c, MailingCity, MailingState WHERE RecordTypeId =: doctorRecordTypeId)];
return searchList[0];
}
}
This function works great in my lightning component. I've tried to apply test coverage
@isTest
private class EditorModalControllerTest {
@testSetup private static void setup() {
String doctorRecordTypeId = Schema.Sobjecttype.Contact.getRecordTypeInfosByName().get('Doctor').getRecordTypeId();
insert new Contact(LastName = 'MCDANIEL', RecordTypeId = doctorRecordTypeId);
}
@isTest private static void searchDoctors() {
System.assertEquals(1, [SELECT count() FROM Contact WHERE LastName = 'MCDANIEL']);
System.assertEquals(1, EditorModalController.searchDoctors('MCDANIEL').size());
}
}
The first assert passes, but the second does not. I don't understand why that is.