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

Refactor Fieldset component test file to new format #3435

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

adi-unni
Copy link
Contributor

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....

  • Do we need any additional tests?
  • Are the tests descriptions clear?
  • Does the order of the test document make sense?
  • Is it internally consistent?
  • Is it consistent with the guidelines for test refactoring?
  • run this test command to view the test results:
  • yarn test --testNamePattern="FOR: Macro: Fieldset"
  • I have selected the correct Assignee
  • I have linked the correct Issue

@adi-unni adi-unni added the Tech improvements Tech debt, cleanup, code standardisation etc. label Nov 21, 2024
@adi-unni adi-unni self-assigned this Nov 21, 2024
Copy link

netlify bot commented Nov 21, 2024

Deploy Preview for ons-design-system-preview ready!

Name Link
🔨 Latest commit 57a8b3a
🔍 Latest deploy log https://app.netlify.com/sites/ons-design-system-preview/deploys/674884c1465718000824f4cd
😎 Deploy Preview https://deploy-preview-3435--ons-design-system-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@rmccar rmccar changed the title Refactor Fieldset component Refactor Fieldset component test file Nov 22, 2024
@rmccar rmccar changed the title Refactor Fieldset component test file Refactor Fieldset component test file to new format Nov 22, 2024
Comment on lines 53 to 54
legend: undefined,
legendIsQuestionTitle: undefined,
Copy link
Contributor

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', () => {
Copy link
Contributor

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

src/components/fieldset/_macro.spec.js Outdated Show resolved Hide resolved
Comment on lines 232 to 237
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('');
});
Copy link
Contributor

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

src/components/fieldset/_macro.spec.js Outdated Show resolved Hide resolved
src/components/fieldset/_macro.spec.js Outdated Show resolved Hide resolved
src/components/fieldset/_macro.spec.js Outdated Show resolved Hide resolved
const title = $('.ons-fieldset__description').html().trim();
expect(title).toBe('A fieldset description');
});
test('THEN: legend has class "ons-fieldset__legend--with-description"', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
test('THEN: legend has class "ons-fieldset__legend--with-description"', () => {
test('THEN: legend has the legend with description class', () => {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tech improvements Tech debt, cleanup, code standardisation etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Testing refactor - Fieldset
2 participants