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

Feature/testing #35

Merged
merged 7 commits into from
Mar 30, 2021
Merged

Feature/testing #35

merged 7 commits into from
Mar 30, 2021

Conversation

trm217
Copy link
Collaborator

@trm217 trm217 commented Mar 23, 2021

Changes requested in Issue 12

This PR includes the following changes:

  1. Setup for testing using Jest and @testing-library/react
  2. Test-suites for the following features:
    • different defaultThemes (4 test-cases)
    • using a custom storage-key (2 test-cases)
    • custom attribute (3 test-cases)
    • custom value-mapping (1 test-case)

@trm217 trm217 mentioned this pull request Mar 23, 2021
@pacocoursey
Copy link
Owner

Amazing! This looks great, I'd be happy to merge already just to have some tests going on future PRs. A few more things we could add tests for:

  • Forced theme
  • Resolved theme (which also handles color-scheme)
  • Ensuring theme is synced across all instances of useTheme hook

@trm217
Copy link
Collaborator Author

trm217 commented Mar 25, 2021

Regarding the test you mentioned, I suppose it would be cool to check those with Integration Tests. Especially for the media-query based one. Cypress might work nicely for that.

I'll add some improvements to the test and afterwards I'll open the PR to be merged.

Thx for the feedback

@trm217
Copy link
Collaborator Author

trm217 commented Mar 25, 2021

@pacocoursey I added a test-suite for the forcedTheme prop, however I am not completely sure if I used it the right way.
Am I correct to assume that I would have to use the forcedTheme value returned by the useTheme hook on the page that has a forced theme?
I was expecting the theme value returned by the hook to be equal to the forcedTheme... 🤔

@trm217 trm217 marked this pull request as ready for review March 29, 2021 21:08
@trm217
Copy link
Collaborator Author

trm217 commented Mar 29, 2021

@pacocoursey Would it be of interest to run the tests on every PR?
Perhaps it would be helpful to set two conditions for a PR to be merge: 1. All test-cases must be successful. 2. The code-coverage can not decrease below a given threshold.
If you could use some help with creating GitHub-actions feel free to contact me, I'd gladly help with that :)

@pacocoursey
Copy link
Owner

I was expecting the theme value returned by the hook to be equal to the forcedTheme

No, currently the hook will return whatever the active theme is (generally the UI should reflect it), then forcedTheme is returned as it's own value.

Would it be of interest to run the tests on every PR?

Yeah, for sure! I'll merge this and set this up to run in GH actions on every PR as a required step.

@trm217
Copy link
Collaborator Author

trm217 commented Mar 29, 2021

Good stuff! Thanks for the pleasant conversations 👍🏻

@pacocoursey pacocoursey merged commit d41a339 into pacocoursey:master Mar 30, 2021
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