Skip to content

Commit

Permalink
fix "blogs" border color, add test for html props passed
Browse files Browse the repository at this point in the history
  • Loading branch information
isastettler committed Oct 10, 2023
1 parent 87cc43d commit 7d141cc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 5 deletions.
30 changes: 28 additions & 2 deletions src/components/NewsletterSignup/NewsletterSignup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ describe("NewsletterSignup Accessibility", () => {

describe("NewsletterSignup Unit Tests", () => {
/** Notes
*
* The newsletterSignupType tests are covered in the snapshot tests below.
*/

Expand All @@ -130,7 +129,7 @@ describe("NewsletterSignup Unit Tests", () => {
expect(screen.getByText(/Privacy Policy/i)).toBeInTheDocument();
});

it("Renders the Optional descriptionText and formHelperText Values for the Form", () => {
it("Renders the Optional descriptionText and formHelperText String Values for the Form", () => {
const testNewsletterSignup = (
<NewsletterSignup
descriptionText="Do not send cash."
Expand All @@ -147,6 +146,33 @@ describe("NewsletterSignup Unit Tests", () => {
expect(screen.getByText(/Just trying to help/i)).toBeInTheDocument();
});

it("Renders the Optional descriptionText and formHelperText HTML Values for the Form", () => {
const testNewsletterSignup = (
<NewsletterSignup
descriptionText={
<div>
Do not send <a href="https://chias.website/">cash</a>.
</div>
}
formHelperText={
<div data-testId="helper-text-container">
Just <strong data-testId="emphasized">trying</strong> to help
</div>
}
onSubmit={onSubmit}
onChange={onChange}
valueEmail={valueEmail}
confirmationHeading="Thank you for signing up!"
confirmationText="You can update your email subscription preferences at any time using the links at the bottom of the email."
/>
);
render(testNewsletterSignup);
const ancestor = screen.getByTestId("helper-text-container");
const descendant = screen.getByTestId("emphasized");
expect(screen.getByRole("link", { name: "cash" })).toBeInTheDocument();
expect(ancestor).toContainElement(descendant);
});

it("calls the onChange on user type event", () => {
render(
<NewsletterSignup
Expand Down
15 changes: 12 additions & 3 deletions src/theme/components/newsletterSignup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,26 @@ const NewsLetterSignup = {
bg: "ui.bg.default",
borderWidth: { base: ".75rem 0px 0px 0px", md: "0px 0px 0px .75rem" },
borderLeftColor: {
md: getSectionColors(newsletterSignupType, "primary"),
md: getSectionColors(
newsletterSignupType,
newsletterSignupType === "blogs" ? "secondary" : "primary"
),
},
borderTopColor: {
base: getSectionColors(newsletterSignupType, "primary"),
base: getSectionColors(
newsletterSignupType,
newsletterSignupType === "blogs" ? "secondary" : "primary"
),
md: "ui.border.default",
},
_dark: {
bg: "dark.ui.bg.default",
borderTopColor: { md: "dark.ui.border.default" },
borderLeftColor: {
md: getSectionColors(newsletterSignupType, "primary"),
md: getSectionColors(
newsletterSignupType,
newsletterSignupType === "blogs" ? "secondary" : "primary"
),
},
},
padding: {
Expand Down

0 comments on commit 7d141cc

Please sign in to comment.