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
swain 10swain 10 

Test Class For Lightning Controller?

public class OV_CountryList {
    @AuraEnabled
    public static List<String> getCountry(){
        List<String> options = new List<String>();
        Schema.DescribeFieldResult fieldResult = User.Countrycode.getDescribe();
        List<Schema.PicklistEntry> plist = fieldResult.getPicklistValues();
        System.debug('Picklist::'+plist);
        for (Schema.PicklistEntry p: pList) {
            System.debug(p.getLabel() +'::'+ p.getValue());
            options.add(p.getLabel());
        }
        return options;
    }
}

In this we are fetching picklist from global picklist
Steven NsubugaSteven Nsubuga
@isTest
private class OV_CountryListTest{
	
	@isTest static void testGetCountry(){
		System.assertEquals(OV_CountryList.getCountry().size(), User.Countrycode.getDescribe().getPicklistValues().size());
	}
}

 
swain 10swain 10
Thanks a lot Steven
Steven NsubugaSteven Nsubuga
You're welcome!