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

Migrate enzyme tests to testing-library #52

Merged
merged 6 commits into from
Apr 13, 2022

Conversation

julienw
Copy link

@julienw julienw commented Apr 12, 2022

I believe that looking at commits individually should make it easier.

@netlify
Copy link

netlify bot commented Apr 12, 2022

Deploy Preview for firefox-devtools-react-contextmenu ready!

Name Link
🔨 Latest commit 48fe4b1
🔍 Latest deploy log https://app.netlify.com/sites/firefox-devtools-react-contextmenu/deploys/6255acb62329f800075f70ee
😎 Deploy Preview https://deploy-preview-52--firefox-devtools-react-contextmenu.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 settings.

@@ -19,7 +19,7 @@
"src/index.d.ts"
],
"scripts": {
"lint": "eslint ./src ./examples",
"lint": "eslint ./src ./tests ./examples",
Copy link
Author

Choose a reason for hiding this comment

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

Curiously the test files weren't checked by eslint.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, interesting. Thanks for adding them!

switch (e.keyCode) {
case 37: // left arrow
case 27: // escape
switch (e.key) {
Copy link
Author

Choose a reason for hiding this comment

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

The user-event library doesn't use keyCode in the event it sends, and this is on purpose. Therefore I moved to e.key in this PR too. I took care to use the older values that Internet Explorer supports as well. I didn't test IE but I trust MDN on those.

See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values for the values for this property.

Copy link
Member

Choose a reason for hiding this comment

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

Works for me. I'm not really worried about IE, but good to include them too :)

@@ -1,17 +1,8 @@
const jsdom = require('jsdom');
Copy link
Author

Choose a reason for hiding this comment

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

This commit has the bulk of the changes. The test files aren't perfect but good enough to move us forward. In the future we can try to improve the coverage.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I feel like these tests are really not enough. But this is something for the future.

@julienw julienw requested a review from canova April 12, 2022 16:52
Copy link
Member

@canova canova left a comment

Choose a reason for hiding this comment

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

Looks good to me with a question about the removed sub-menu-wrapper-test.js file. Not sure if it was intentionally removed or not.
Thanks!

@@ -19,7 +19,7 @@
"src/index.d.ts"
],
"scripts": {
"lint": "eslint ./src ./examples",
"lint": "eslint ./src ./tests ./examples",
Copy link
Member

Choose a reason for hiding this comment

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

Ah, interesting. Thanks for adding them!

switch (e.key) {
case 'ArrowLeft': // left arrow
case 'Left': // IE specific value
case 'Escape': // escape
Copy link
Member

Choose a reason for hiding this comment

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

I guess some of the comments are now redundant, but I don't mind keeping them.

switch (e.keyCode) {
case 37: // left arrow
case 27: // escape
switch (e.key) {
Copy link
Member

Choose a reason for hiding this comment

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

Works for me. I'm not really worried about IE, but good to include them too :)

@@ -1,29 +0,0 @@


import React from 'react';
Copy link
Member

Choose a reason for hiding this comment

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

Unlike sub-menu-tests.js, I don't see the new file of this SubMenuWrapper component. Is that intentional or is it because of a slipped git add? :)

Copy link
Author

Choose a reason for hiding this comment

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

as we discussed, this test file wasn't run before, and is about a component that doesn't seem present anymore.

@@ -1,17 +1,8 @@
const jsdom = require('jsdom');
Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I feel like these tests are really not enough. But this is something for the future.

@julienw julienw merged commit 528a6cd into firefox-devtools:master Apr 13, 2022
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.

2 participants