+ Start a Discussion
Parth SrivastavaParth Srivastava 

help with test class for auraEnabled

public with sharing class HotAccountController {
  public HotAccountController() {  
  }

  @AuraEnabled
  public static Boolean isAccountHot(String accId){
    Account objAccount = [Select Hot_Account__c, Id from Account WHERE Id =: accId];
    return objAccount.Hot_Account__c;
  }

  @AuraEnabled
  public static Boolean callApproval(String accId){
      try{
      UpdateAccount.callApproval(accId);
      return true;
    }catch(Exception excpt){
      return false;
    }
  }
}
Best Answer chosen by Parth Srivastava
$hwet@$hwet@
Hi Parth,

Please find below the test class and please update the account record based on the condition of " UpdateAccount.callApproval(accId);"

 @isTest
private class HotAccountControllerTest{
     static testmethod void isAccountHotTest(){
     Account acc1 =  new Account(name='test',Hot_Account__c=True);
     insert acc1;
         HotAccountController.isAccountHot(string.valueof(acc1.id));
     }
     static testmethod void constructorTest(){
         HotAccountController hht = new HotAccountController();
     }
     static testmethod void callApprovalTest(){
        Account acc1 =  new Account(name='test',Hot_Account__c=True);
        insert acc1;
        HotAccountController.callApproval(string.valueof(acc1.id));
     }   
}