-
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 Autosuggest component test file to new format #3327
base: main
Are you sure you want to change the base?
Refactor Autosuggest component test file to new format #3327
Conversation
✅ Deploy Preview for ons-design-system-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
I think some more work needs to be done here, use one of the other PRs as a template. We are missing the "FOR" and "THEN" in some cases
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.
Just some minor comments that I think make sense with the testing rules we have set in the documentation
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.
Ive realised we are missing tests for the language and resultsThreshold params. I think we should add these
test('THEN: it has language set to "en-gb"', () => { | ||
expect($('.ons-autosuggest').attr('data-lang')).toBe('en-gb'); | ||
}); |
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.
Only required params should be inside this "when" unless you are testing defaults. I don't think this param is required and theres probably a few others too such as the result threshold one. I think we need to review these, keep the ones that test defaults move the others. Then for the ones that have defaults make sure the defaults are tested here and have another test to test what you pass in is overriding that default
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.
I think the params still need to be reviewed. Theres still some params in there that aren't required
6096db1
to
9915198
Compare
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.
I think you need to check the required the params in the documentation some of these in the required describe aren't required still. Also the "params none" describe you've added actually passes in a lot of params because it uses EXAMPLE_AUTOSUGGEST
. I don't think we need this describe though, we should be testing these things with the required params because we expect those params to be passed in
b7fe5c4
to
1f43ccc
Compare
@@ -18,4 +18,4 @@ | |||
| input | `Input` [_(ref)_](/components/input) | true | Configuration object for the input | | |||
| language | string | false | The ISO 639-1 Code will override the default language in page. Please note that only 'en', 'cy' and 'ni' is currently supported | | |||
| resultsThreshold | float | false | Option to adjust the search threshold and fuzziness. Accepts a range from 0 to 1, where 0 provides the closest match and 1 allows for more distant matches. Defaults to 0.2. | | |||
| id | string | false | The `id` of the input | | |||
| id | string | true | The `id` of the input | |
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.
I assume this is a correction rather than an alteration since I can't see a change in the code to require this field and there is no mention in the ticket itself?
What is the context of this PR?
Fixes: ONSdigital/design-team#134
This PR involves refactoring of the autosuggest test document to follow the Given, When, Then testing approach.
How to review this PR
Functionality:
Does this testing refactor meet the following success criteria:
Look at the refactored code in relation to:
Checklist
This needs to be completed by the person raising the PR.