Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(button-bar): convert enzyme test to rtl #6737

Merged
merged 3 commits into from
May 30, 2024
Merged

chore(button-bar): convert enzyme test to rtl #6737

merged 3 commits into from
May 30, 2024

Conversation

tomdavies73
Copy link
Contributor

Proposed behaviour

Converts enzyme tests to rtl.

Current behaviour

Current tests are written in enzyme.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

Comment on lines 64 to 65
expect(button).toHaveStyle("font-size: var(--fontSizes100)");
expect(button).toHaveStyle("min-height: 40px");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion(non-blocking): toHaveStyle accepts an object so you could put these into one assertion. I'm happy with either way. It's just whichever way we decide we want to do it going forward.

Suggested change
expect(button).toHaveStyle("font-size: var(--fontSizes100)");
expect(button).toHaveStyle("min-height: 40px");
expect(button).toHaveStyle({
fontSize: "var(--fontSizes100)",
minHeight: "40px",
});

@Parsium Parsium self-requested a review May 29, 2024 08:05
Comment on lines +66 to +71
const ariaLabelValue =
ariaLabel ||
(internalRef?.querySelector(
"[data-component='icon']"
) as Element)?.getAttribute("type") ||
"";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

praise: nice one for removing this decoupling 👍

});
});

it("should render the Buttons with the 'iconPosition' prop set to 'before'", () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion(non-blocking): how about we amend a few of test titles to make the intended behavior clearer? This way, if something breaks and a test fails, it will be easier for us to understand what the component is supposed to do.

For example:

it("renders icon with right margin when iconPosition prop is 'before'");
it("does not render Buttons with full width when fullWidth prop is false");

I appreciate that most of the tests are checking trivial CSS rules though, so I'll leave this up to you. What are your thoughts?

@Parsium Parsium marked this pull request as ready for review May 30, 2024 08:43
@tomdavies73 tomdavies73 merged commit 973c269 into master May 30, 2024
22 checks passed
@tomdavies73 tomdavies73 deleted the FE-6559 branch May 30, 2024 08:52
@carbonci
Copy link
Collaborator

🎉 This PR is included in version 136.0.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants