-
Notifications
You must be signed in to change notification settings - Fork 187
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
Fix fontFamily being set to undefined #252
base: master
Are you sure you want to change the base?
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 👍 |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
instanceof
OrderedElement
for thefontFamily
StringHandler
helper 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
OrderedElement
have a different shape. I added a check if it was of typeOrderedElement
and so go about using it's getter functionOrderedElement.get()
otherwise just on the object directly.