You need to sign in to do that
Don't have an account?
SUMIT BANERJEE
How to write test class for lightning controller
global class LightningForgotPasswordController {
public LightningForgotPasswordController() {
}
@AuraEnabled
public static String forgotPassowrd(String username, String checkEmailUrl) {
try {
Site.forgotPassword(username);
ApexPages.PageReference checkEmailRef = new PageReference(checkEmailUrl);
if(!Site.isValidUsername(username)) {
return Label.Site.invalid_email;
}
aura.redirect(checkEmailRef);
return null;
}
catch (Exception ex) {
return ex.getMessage();
}
}
}
public LightningForgotPasswordController() {
}
@AuraEnabled
public static String forgotPassowrd(String username, String checkEmailUrl) {
try {
Site.forgotPassword(username);
ApexPages.PageReference checkEmailRef = new PageReference(checkEmailUrl);
if(!Site.isValidUsername(username)) {
return Label.Site.invalid_email;
}
aura.redirect(checkEmailRef);
return null;
}
catch (Exception ex) {
return ex.getMessage();
}
}
}
Obviously you'd have to replace 'test@test.test' with an appropriate username associated with your site and you'd want to test against invalid usernames etc, but hopefully you get the idea.