-
Notifications
You must be signed in to change notification settings - Fork 9
Write test for utility functions #15
base: next
Are you sure you want to change the base?
Conversation
Hi @luann112 , thanks for this PR. |
}) | ||
|
||
it('Should return a boolean value', async () => { | ||
const result = await checkIsUrlOk('fb.com') |
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.
Can you mock for this effect? don't call to network!
import compareFilesByHash from './compareFilesByHash' | ||
|
||
describe('compareFilesByHash', () => { | ||
it('Exported as default', () => { |
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.
Don't need this case, should you remove:
import * as func from './compareFilesByHash'
import deferedPromise from './deferedPromise' | ||
|
||
describe('deferedPromise', () => { | ||
it('Exported as default', () => { |
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.
Please handle (remove) as the case above
|
||
describe('ensureOrigin', () => { | ||
it('Exported as default', () => { | ||
expect(func.default).toBeDefined() |
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.
This is the same
}) | ||
|
||
it('Should match to snapshot', () => { | ||
expect(deferedPromise()).toMatchSnapshot() |
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.
Please check the prototype instead of using snapshot for this case
}) | ||
|
||
it('Should match to the snapshot', () => { | ||
const path = require.resolve('./hashFile') |
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.
Can you mock or stub test file?
@@ -0,0 +1,23 @@ | |||
import * as func from './jsonHelpers' |
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.
Use jsonHelpers
instead of func
@@ -0,0 +1,31 @@ | |||
import * as func from './linkedUrls' |
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.
Use linkedUrls
instead of func
@@ -0,0 +1,15 @@ | |||
import * as func from './checkIsProductionMode' |
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.
Use checkIsProductionMode
insead of func
.
With a file export default only don't need to use:
import * as func from './checkIsProductionMode'
Use below:
import checkIsProductionMode from './checkIsProductionMode'
const fileA = require.resolve('./compareFilesByHash') | ||
const fileB = require.resolve('./deferedPromise') | ||
expect(compareFilesByHash(fileA, fileB)).toBe(false) | ||
}) |
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.
Can you update compareFilesByHash
and throw an error if files received not found?
@luann112 I commented something, please help me update it. Don't forget to rebase with the |
No description provided.