mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2026-02-11 10:05:41 +00:00
feat: add aria labels to widget progress bar and checkbox
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
|
||||
import * as CONST from "../const";
|
||||
|
||||
import {getBaseHtml, sitekey, checkbox} from "./setupTests";
|
||||
import { getBaseHtml, sitekey, checkbox } from "./setupTests";
|
||||
import * as TESTElements from "./setupTests";
|
||||
|
||||
it("const works", () => {
|
||||
@@ -17,29 +17,17 @@ it("const works", () => {
|
||||
|
||||
// display after
|
||||
CONST.messageText().after();
|
||||
expect(TESTElements.afterMsg.style.display).toBe("block");
|
||||
expect(TESTElements.beforeMsg.style.display).toBe("none");
|
||||
expect(TESTElements.duringMsg.style.display).toBe("none");
|
||||
expect(TESTElements.errorMsg.style.display).toBe("none");
|
||||
expect(TESTElements.Msg.innerText).toBe(CONST.AFTER);
|
||||
|
||||
// display before
|
||||
CONST.messageText().before();
|
||||
expect(TESTElements.afterMsg.style.display).toBe("none");
|
||||
expect(TESTElements.beforeMsg.style.display).toBe("block");
|
||||
expect(TESTElements.duringMsg.style.display).toBe("none");
|
||||
expect(TESTElements.errorMsg.style.display).toBe("none");
|
||||
expect(TESTElements.Msg.innerText).toBe(CONST.BEFORE);
|
||||
|
||||
// display during
|
||||
CONST.messageText().during();
|
||||
expect(TESTElements.afterMsg.style.display).toBe("none");
|
||||
expect(TESTElements.beforeMsg.style.display).toBe("none");
|
||||
expect(TESTElements.duringMsg.style.display).toBe("block");
|
||||
expect(TESTElements.errorMsg.style.display).toBe("none");
|
||||
expect(TESTElements.Msg.innerText).toBe(CONST.DURING);
|
||||
|
||||
// display error
|
||||
CONST.messageText().error();
|
||||
expect(TESTElements.afterMsg.style.display).toBe("none");
|
||||
expect(TESTElements.beforeMsg.style.display).toBe("none");
|
||||
expect(TESTElements.duringMsg.style.display).toBe("none");
|
||||
expect(TESTElements.errorMsg.style.display).toBe("block");
|
||||
expect(TESTElements.Msg.innerText).toBe(CONST.ERROR);
|
||||
});
|
||||
|
||||
@@ -11,25 +11,19 @@ export const checkbox = <HTMLInputElement>document.createElement("input");
|
||||
checkbox.type = "checkbox";
|
||||
checkbox.id = CONST.btnId;
|
||||
|
||||
const getMessages = (state: string) => {
|
||||
const getMessages = () => {
|
||||
const msg = <HTMLElement>document.createElement("span");
|
||||
msg.id = `widget__verification-text--${state}`;
|
||||
msg.id = "widget__verification-text";
|
||||
msg.innerText = "I'm not a robot";
|
||||
return msg;
|
||||
};
|
||||
|
||||
export const beforeMsg = getMessages("before");
|
||||
export const afterMsg = getMessages("after");
|
||||
export const duringMsg = getMessages("during");
|
||||
export const errorMsg = getMessages("error");
|
||||
export const Msg = getMessages();
|
||||
|
||||
/** get base HTML with empty mCaptcha container */
|
||||
export const getBaseHtml = (): HTMLFormElement => {
|
||||
const form = <HTMLFormElement>document.createElement("form");
|
||||
form.appendChild(checkbox);
|
||||
form.appendChild(beforeMsg);
|
||||
form.appendChild(duringMsg);
|
||||
form.appendChild(afterMsg);
|
||||
form.appendChild(errorMsg);
|
||||
|
||||
form.appendChild(Msg);
|
||||
return form;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user