Fix fontFamily being set to undefined#252
Conversation
|
Hey @dwayne-roberts, Thanks for the PR! Mind signing our Contributor License Agreement? When you've done so, go ahead and comment Yours truly, |
|
[clabot:check] |
|
CLA signature looks good 👍 |
xymostech
left a comment
There was a problem hiding this comment.
Hey @dwayne-roberts! Thanks for the PR.
It looks like the travis coverage tests are failing because you didn't add a test to check that these two lines work. Can you add those? Other than that, this looks great!
| if (val instanceof OrderedElements) { | ||
| // We need to generate a unique key by which we can identify | ||
| // this declaration in the the 'alreadyInjected' object | ||
| key = `fontface_${hashObject(val)}`; |
There was a problem hiding this comment.
Is there a reason we're not just using val.get('src') to be consistent with how we generate the key normally?
There was a problem hiding this comment.
Sorry for the late reply, was away. No, there isn't a reason I didn't use val.get(). Good point. I'll change it to be consistent like you said. Thanks. And I'll also add the tests.
|
@dwayne-roberts ping on this? Would love to get this merged :) |
|
@xymostech could you point me in the right direction for the test? Unfortunately I have little experience with these type of test. I only ever used Jest and snapshot tests. :-( |
|
The coverage tests make sure that all branches in the code are tested. We do that by running the tests and then seeing all of the lines that they hit. In this case, there's a line in the failing coverage tests that says which means that lines 75 and 76 of src/inject.js aren't getting hit during the tests. Looking at the code, it's just the new branch that you added in, which indicates that there isn't a test for the new code that you wrote. So, writing a test here: https://github.com/Khan/aphrodite/blob/master/tests/inject_test.js#L333 that hits this change would probably fix this. You can run Hopefully that should help! Let me know if anything is still confusing. :) |
Added a check for an
instanceofOrderedElementfor thefontFamilyStringHandlerhelper function.There was a check if the value passed was an Array, Object or String. When it was an Object it keys were accessed directly. But Objects of type
OrderedElementhave a different shape. I added a check if it was of typeOrderedElementand so go about using it's getter functionOrderedElement.get()otherwise just on the object directly.