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
Variants unit tests #1235
Variants unit tests #1235
Conversation
add first small snaphsot test
add building tests and add tests for boundaries (prop functions) that are beeing called on click consider using the info.json object instead of hard-coding it (might be easier to maintain)
Codecov Report
@@ Coverage Diff @@
## master #1235 +/- ##
==========================================
+ Coverage 24.11% 26.59% +2.47%
==========================================
Files 213 212 -1
Lines 8053 8186 +133
Branches 1788 1833 +45
==========================================
+ Hits 1942 2177 +235
+ Misses 5535 5433 -102
Partials 576 576
Continue to review full report at Codecov.
|
re: considerations:
We are likely to introduce new flags over time with the same purpose, even though the flags that previously used this functionality have been deprecated.
One habit I have is always having a default case in switch. There may even be an eslint rule for it? It's true that this is not strictly necessary here. Are you suggesting setting |
also the way to test the flag code for future icons with enabled flag the transformation to json did not work on first try, because jest could not handle them correctly in the mock folder via automock; needs to be investigated
@louh added the |
@louh seems to be a bug in jest |
Doesn't look there's a lot of activity on that issue, which is a little discouraging. In the meantime, I think we should just leave it as a mocked JS module. |
@milafrerichs Actually, I just realized we did mock out a JSON previously, this way: streetmix/assets/scripts/streets/__tests__/environs.test.js Lines 8 to 10 in 555c606
What do you think? |
since it's only a json object anyway we can just use json due to a bug in jest we cannot use the automock for the json file directly but have to implicitly require the file
What does this PR do?
It adds unit and snapshot tests to
Variants.jsx
Things to consider
removing the flag codethe flags where deleted in this commit: 7b966a5#diff-85807e1af4b159a1efc2be65bdb172db
so they probably should be deleted here as well
removing default case inswitch
https://github.com/streetmix/streetmix/pull/1235/files#diff-d38d718d141d25ed5e3dfdfd85783056R77
for example if there is no type set, then there are no variants and there will be nothing rendered, not sure if these defaults in the
switch
are necessary.Is there a case when the
this.state.variantSets
is set but thetype
is not set?__mocks__
folder for variant_icons