-
Notifications
You must be signed in to change notification settings - Fork 21
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
Refactor Fieldset component test file to new format #3435
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for ons-design-system-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
legend: undefined, | ||
legendIsQuestionTitle: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing undefined in other tests we have gone with the pattern of not passing the var at all. Also In this case if you wanted to not pass in legend you have EXAMPLE_FIELDSET_NO_LEGEND to use rather than overriding it in this way.
|
||
describe('FOR: Macro: Fieldset', () => { | ||
describe('GIVEN: Params: required', () => { | ||
describe('WHEN: all required params are provided', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The params passed in for this test aren't required ones, I don't think we have any required params for this component, its just some params require other params to be set. So these tests should be moved out into their own GIVENs
test('THEN: renders legend as H1 with empty text', () => { | ||
const titleTag = $('.ons-fieldset__legend-title')[0].tagName; | ||
expect(titleTag).toBe('h1'); | ||
const titleText = $('.ons-fieldset__legend-title').text().trim(); | ||
expect(titleText).toBe(''); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rendering an empty <h1>
isnt something that we necessarily want to happen so I don't think we need to test for this
const title = $('.ons-fieldset__description').html().trim(); | ||
expect(title).toBe('A fieldset description'); | ||
}); | ||
test('THEN: legend has class "ons-fieldset__legend--with-description"', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test('THEN: legend has class "ons-fieldset__legend--with-description"', () => { | |
test('THEN: legend has the legend with description class', () => { |
What is the context of this PR?
Fixes: #156
Refactors the fieldset component test file to the new agreed format.
How to review this PR
Run tests locally and check that the messages make sense and describe what is being tested
Ask yourself....
yarn test --testNamePattern="FOR: Macro: Fieldset"