Skip to content

Add tests for molecules input form field#68

Merged
brandongregoryscott merged 8 commits into
rsm-hcd:mainfrom
SaidShah:add-tests-for-molecules-input-form-field
Nov 4, 2020
Merged

Add tests for molecules input form field#68
brandongregoryscott merged 8 commits into
rsm-hcd:mainfrom
SaidShah:add-tests-for-molecules-input-form-field

Conversation

@SaidShah
Copy link
Copy Markdown
Contributor

  • Related GitHub issue(s) linked in PR description
  • Destination branch merged, built and tested with your changes
  • Code formatted and follows best practices and patterns
  • Code builds cleanly (no additional warnings or errors)
  • Manually tested
  • Automated tests are passing
  • No decreases in automated test coverage
  • Documentation updated (readme, docs, comments, etc.)
  • Localization: No hard-coded error messages in code files (minimally in string constants)
  • New component and/ or properties? Make sure to update storybook

Closes #24

@codecov
Copy link
Copy Markdown

codecov Bot commented Oct 29, 2020

Codecov Report

Merging #68 into main will increase coverage by 3.26%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #68      +/-   ##
==========================================
+ Coverage   25.66%   28.93%   +3.26%     
==========================================
  Files          51       51              
  Lines         900      902       +2     
  Branches      209      209              
==========================================
+ Hits          231      261      +30     
+ Misses        662      639      -23     
+ Partials        7        2       -5     
Impacted Files Coverage Δ
src/atoms/buttons/button.tsx 100.00% <ø> (ø)
src/atoms/forms/input-character-count.tsx 100.00% <ø> (ø)
src/atoms/forms/password-input.tsx 100.00% <ø> (ø)
src/atoms/forms/text-input.tsx 100.00% <ø> (+100.00%) ⬆️
src/atoms/progress-bar/progress-bar.tsx 100.00% <100.00%> (+100.00%) ⬆️
src/molecules/form-fields/input-form-field.tsx 100.00% <100.00%> (+31.25%) ⬆️
src/molecules/form-fields/checkbox-form-field.tsx 100.00% <0.00%> (+16.66%) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 757bd1a...7c4da15. Read the comment docs.

// Arrange
const label = faker.random.words();
const firstErrorMessage = faker.random.words();
const secondErrorMessage = faker.random.words();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nitpick: try to avoid numerical/sequential naming of test variables unless it has a meaning (ie, we are actually expecting firstErrorMessage to be the first result in a returned list). If the order & value do not really matter, this could be wrapped up in an array:

const errorMessages = [faker.random.words(), faker.random.words()];

Honestly, this might be a good candidate as a TestUtil method in our JS testing package (I know I've done a similar thing a few places, too)

import {
InputFormField,
InvalidInputFormValueClass,
ShowLabelForScreenReadersOnlyClass,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could these two classnames be namespaced to the InputFormField component? something a little more descriptive but hopefully not too verbose -

InputFormFieldInvalidClass
InputFormFieldScreenReaderLabelClass


const COMPONENT_CLASS = "c-form-field";
export const InvalidInputFormValueClass = "-invalid";
export const ShowLabelForScreenReadersOnlyClass = "sr-only";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually, now that I'm seeing this, I think this is a pretty common classname we use for screenreader labels/accessibility. Do a quick search in the codebase, but we could probably promote this classname to a constant outside of this component and share it around

@SaidShah
Copy link
Copy Markdown
Contributor Author

SaidShah commented Nov 4, 2020

@brandongregoryscott - Thanks for the feedback. I have made some changes based on your comments if you would like to take another look. 👍

Copy link
Copy Markdown
Contributor

@brandongregoryscott brandongregoryscott left a comment

Choose a reason for hiding this comment

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

@SaidShah Thanks for making that update! Just some final restructuring of where that enum is & it's good to go 👍

@@ -0,0 +1,3 @@
export enum AccessibilityLabels {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this be moved to an enums folder instead of constants? Really nitpicky, but it's a little misleading otherwise.

Additionally, I'd move the folder up a level (not nested under atoms) - seeing as we're already using it in a molecule, it doesn't seem specific to atom components.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree. Done. 👍

@brandongregoryscott brandongregoryscott merged commit 2e62fd1 into rsm-hcd:main Nov 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backfill test for Molecules/InputFormField

3 participants