-
Notifications
You must be signed in to change notification settings - Fork 25
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
Add more complete unit tests #28
Conversation
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.
Nice work @erickzhao! Small stuff to look at.
__tests__/config.js
Outdated
// require config after setting mock platform | ||
const config = require('../lib/config'); | ||
|
||
expect(config.binName === 'theme.exe').toBe(true); |
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.
Minor, but could be:
expect(config.binName).toBe('theme.exe');
@@ -0,0 +1,18 @@ | |||
/* eslint-disable no-use-before-define */ | |||
const src = jest.fn(() => binWrapperObject); |
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.
Wouldn't binWrapperObject throw a ReferenceError at this point since const
variables are not hoisted and is binWrapperObject is declared below?
Or I guess it is not referenced until this callback is called... in which case binWrapperObject is declared in the parent scope? 🤔
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.
Honestly not sure at all. I just tried stuff until it worked for this one, which was tricky since I needed the mutually recursive definitions. In any case, the mock seems to behave as expected. 🤷🏻♂️
|
||
test('rejects promise if error in installation run', () => { | ||
const errorMessage = 'some err'; | ||
run.mockImplementationOnce((_, cb) => { |
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.
Nice use of mockImplementationOnce()
👍
__tests__/logger.js
Outdated
}); | ||
|
||
test('defaults to level 2 without input parameters', () => { | ||
const log = logger('info'); |
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.
Do you mean to have logger()
here? This test is identical to the one on line 52.
@t-kelly made some small fixes! :) Tests still passing. |
What are you trying to accomplish with this PR?
Adds more complete unit tests, including the missing
logger
andinstall
files. Also fixed a bug in/lib/logger.js
not accepting multiple parameters.Jest coverage output
Checklist
For contributors:
For maintainers:
package.json
version in a separate PR, if applicable.Considerations:
@shopify/slate-tools
package.