mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
add site form validation tests
This commit is contained in:
@@ -23,6 +23,8 @@ import {getLoginFormHtml} from '../setUpTests';
|
||||
const formClassName = 'form__box';
|
||||
const formURL = '/api/v1/signin';
|
||||
|
||||
const noFormErr = "Can't find form";
|
||||
|
||||
document.body.innerHTML = getLoginFormHtml();
|
||||
|
||||
const form = document.querySelector('form');
|
||||
@@ -37,4 +39,11 @@ it('getFromUrl workds', () => {
|
||||
expect(getFormUrl(form)).toContain(formURL);
|
||||
|
||||
expect(getFormUrl()).toContain(formURL);
|
||||
|
||||
try {
|
||||
document.body.innerHTML = formURL;
|
||||
getFormUrl();
|
||||
} catch (e) {
|
||||
expect(e.message).toContain(noFormErr);
|
||||
}
|
||||
});
|
||||
@@ -33,7 +33,7 @@ const getFormUrl = (querySelector?: string | HTMLFormElement) => {
|
||||
form = querySelector;
|
||||
}
|
||||
|
||||
if (form !== undefined) {
|
||||
if (form !== undefined && form !== null) {
|
||||
return form.action;
|
||||
} else {
|
||||
throw new Error("Can't find form");
|
||||
|
||||
Reference in New Issue
Block a user