function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RaffusRaffus 

How to write a test method for this

@AuraEnabled
    public static void saveCustomerInfo(String data, String partyId, String mobile) {
        rand_App_Customer__c customer = (rand_App_Customer__c) JSON.deserialize(data, rand_App_Customer__c.class);
        customer.Party_Id__c = String.isBlank(partyId) ? mobile : partyId;
        customer.Customer_ID__c = customer.Party_Id__c;
        customer.Customer_Mobile__c = mobile;
        if (String.isNotBlank(mobile)) {
            customer.Id = [SELECT Id FROM rand_App_Customer__c WHERE Customer_Mobile__c = :mobile LIMIT 1]?.Id;
        }
        customer.recalculateFormulas();
        customer.Name = String.isBlank(customer.Customer_Name__c) ? 'User' : customer.Customer_Name__c;
        upsert customer Customer_ID__c;
    }