-2
public with sharing class ToggleController {
    @AuraEnabled(cacheable=true)

    public static List< Contact > fetchContact (Id accId, String status) {

        return [SELECT Status_c, FirstName, LastName, Email
                FROM Contact WHERE Status_c=: status AND AccountId=:accid ];
    }
}
0

1 Answer 1

1

You can follow below steps -

  1. Prepare data in @testSetup - create account and contact with status__c and accountId of inserted account.
  2. Create a @isTest method and query the account. Call the fetchContact method and pass the accountId and contact's status as mentioned in the @testSetup method.

You can follow below best practices of test class- https://trailhead.salesforce.com/content/learn/modules/apex_testing/apex_testing_data

Not the answer you're looking for? Browse other questions tagged .