I have this DynamicPickList
class that creates picklist values based on what lookups have been put on the Contact object. It is used in the targetConfigs of a LWC. How do I write a test for this class? It didn't seem like you can just
public class Picklist_ContactLookups extends VisualEditor.DynamicPickList{
String defaultVal = '-- none --';
public override VisualEditor.DataRow getDefaultValue(){
VisualEditor.DataRow defaultValue = new VisualEditor.DataRow(defaultVal, defaultVal);
return defaultValue;
}
public override VisualEditor.DynamicPickListRows getValues() {
VisualEditor.DynamicPickListRows lookupsList = new VisualEditor.DynamicPickListRows();
List<String> formLookups = Util.findAllLookupsOnContact();
VisualEditor.DataRow noneValue = new VisualEditor.DataRow(defaultVal, defaultVal);
lookupsList.addRow(noneValue);
for (String lookup : formLookups) {
VisualEditor.DataRow value = new VisualEditor.DataRow(lookup, lookup);
lookupsList.addRow(value);
}
return lookupsList;
}
}
I tried to call
VisualEditor.DynamicPickListRows rows = Picklist_ContactLookups.getValues();
from the test and got "Non static method cannot be referenced from a static context: VisualEditor.DynamicPickListRows Picklist_ContactLookups.getValues()". The Util.findAllLookupsOnContact();
already has its own test.