Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardcho1231 committed Mar 22, 2024
1 parent 4847c64 commit 57eb86f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const BotChallengeProtection = ({ challengeIn, setCaptchaToken, className, captc
onChange={onChange}
onExpired={() => {}}
/>}
{captchaError && <Paragraph>{phrases.t("identity-block.bot-protection-error")}</Paragraph>}
{captchaError && <Paragraph data-testid="bot-challege-captcha-error">{phrases.t("identity-block.bot-protection-error")}</Paragraph>}
</section>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
Expand Down Expand Up @@ -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(<BotChallengeProtection challengeIn="test" />);
expect(screen.queryByTestId("bot-challege-protection-container")).toBeNull();
});
});

0 comments on commit 57eb86f

Please sign in to comment.