Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+30
@@ -0,0 +1,30 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import Captcha from "./Captcha";
|
||||
|
||||
describe("Captcha CAP status contract", () => {
|
||||
it("reports solve, reset and client errors to the enclosing form", () => {
|
||||
const onStatusChange = vi.fn();
|
||||
const { container } = render(
|
||||
<Captcha enabled provider="cap" instanceUrl="https://captcha.example.test" sitekey="registration" onStatusChange={onStatusChange} />
|
||||
);
|
||||
const widget = container.querySelector("cap-widget");
|
||||
|
||||
expect(widget).not.toBeNull();
|
||||
expect(onStatusChange).toHaveBeenLastCalledWith("pending");
|
||||
widget!.dispatchEvent(new CustomEvent("solve"));
|
||||
expect(onStatusChange).toHaveBeenLastCalledWith("solved");
|
||||
widget!.dispatchEvent(new CustomEvent("reset"));
|
||||
expect(onStatusChange).toHaveBeenLastCalledWith("pending");
|
||||
widget!.dispatchEvent(new CustomEvent("error"));
|
||||
expect(onStatusChange).toHaveBeenLastCalledWith("error");
|
||||
});
|
||||
|
||||
it("renders nothing when the public provider configuration is incomplete", () => {
|
||||
const { container } = render(<Captcha enabled provider="cap" />);
|
||||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user