From 57eb86fdd4108c4f102449fe4d72502bcc489bc7 Mon Sep 17 00:00:00 2001 From: Edward Cho Date: Fri, 22 Mar 2024 14:24:20 -0400 Subject: [PATCH] update tests --- .../components/bot-challenge-protection/index.jsx | 2 +- .../bot-challenge-protection/index.test.jsx | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/blocks/identity-block/components/bot-challenge-protection/index.jsx b/blocks/identity-block/components/bot-challenge-protection/index.jsx index a228c77da..44f4a0696 100644 --- a/blocks/identity-block/components/bot-challenge-protection/index.jsx +++ b/blocks/identity-block/components/bot-challenge-protection/index.jsx @@ -56,7 +56,7 @@ const BotChallengeProtection = ({ challengeIn, setCaptchaToken, className, captc onChange={onChange} onExpired={() => {}} />} - {captchaError && {phrases.t("identity-block.bot-protection-error")}} + {captchaError && {phrases.t("identity-block.bot-protection-error")}} ); }; diff --git a/blocks/identity-block/components/bot-challenge-protection/index.test.jsx b/blocks/identity-block/components/bot-challenge-protection/index.test.jsx index e2496460d..b1f5a40b0 100644 --- a/blocks/identity-block/components/bot-challenge-protection/index.test.jsx +++ b/blocks/identity-block/components/bot-challenge-protection/index.test.jsx @@ -1,5 +1,6 @@ import React from "react"; import { render, screen } from "@testing-library/react"; +import { useIdentity } from "@wpmedia/arc-themes-components"; import BotChallengeProtection from "."; const mockLogin = jest.fn(() => Promise.resolve()); @@ -36,4 +37,14 @@ describe("Bot challenge protection", () => { expect(screen.getByTestId("bot-challege-protection-container")).not.toBeNull(); }); + it("it does not render if identity is not initialized", () => { + useIdentity.mockImplementation(() => ({ + isInitialized: false, + Identity: { + ...mockIdentity, + }, + })) + render(); + expect(screen.queryByTestId("bot-challege-protection-container")).toBeNull(); + }); });