-
Notifications
You must be signed in to change notification settings - Fork 0
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
increasing test coverage #1217
increasing test coverage #1217
Conversation
@@ -1,6 +1,4 @@ | |||
import { shallow } from 'enzyme'; | |||
import React from 'react'; | |||
import toJSON from 'enzyme-to-json'; |
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.
You still need toJSON
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.
😭
So this PR actually shows a lower coverage than dev lol because of our new React16 components(Bureau). I'm going to give that hook testing library another shot 🤞 |
...leDashboard/UserProfile/UserProfileGeneralInformation/UserProfileGeneralInformation.test.jsx
Outdated
Show resolved
Hide resolved
@@ -29,6 +53,38 @@ describe('UserProfileGeneralInformationComponent', () => { | |||
expect(toJSON(wrapper)).toMatchSnapshot(); | |||
}); | |||
|
|||
// could not get these to work :[ |
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.
Those ids are generated. You'll need to stub the function that generates ids so that the output is consistent/static
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.
oh yeaa, i remember something like generateShortID
🤔
very nice! even if it doesn't bring up the numbers, this makes our tests more comprehensive |
it('get Employee Profile URL', (done) => { | ||
({ mock, spy } = spyMockAdapter({ | ||
url: 'HR/Employees/4/EmployeeProfileReportByCDO', | ||
response: [200, { data: 'arraybuffer', | ||
type: 'application/pdf' }], | ||
})); mock(); |
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.
@mjoyce91 couldn't figure it out. RIP. EmployeeProfileReportByCDO
url and downloadPdfBlob()
handle the request different than About. I'll take out for now. Just committed it to keep a history.
({ mock, spy } = spyMockAdapter({ | ||
url: 'HR/Employees/4/EmployeeProfileReportByCDO', | ||
response: [200, { data: 'arraybuffer', | ||
type: 'application/pdf' }], | ||
})); mock(); | ||
|
||
expectMockWasCalled({ spy, cb: done }); |
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.
You're never making the network request from the component - lines 67-71 only mock the network request, but they don't actually make the network request. So you'll need to call wrapper.instance().getEmployeeProfile()
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.
Does mock()
just create the mock network request?
it('get Employee Profile URL', (done) => { | ||
let mock; | ||
let spy; | ||
({ mock, spy } = spyMockAdapter({ | ||
url: 'HR/Employees/4/EmployeeProfileReportByCDO', | ||
response: [200, { data: 'arraybuffer', | ||
type: 'application/pdf' }], | ||
})); mock(); | ||
|
||
const wrapper = shallow(<UserProfileGeneralInformation.WrappedComponent | ||
userProfile={bidderUserObject} | ||
/>); | ||
|
||
wrapper.instance().getEmployeeProfile(); | ||
|
||
expectMockWasCalled({ spy, cb: done }); | ||
}); |
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.
Did not work... 😭
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.
also tried passing in getEmployeeProfile
as a prop ()
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.
Ah I see. Your URL on line 68 is wrong. It doesn't have a leading slash, but more importantly, EmployeeProfileReportByCDO doesn't get called by api()
, which is what spyMockAdapter
uses. It gets a URL returned by our API. We can skip this for now
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.
I was like 🤔 hitting the store... but why lol
Dang, that leading slash always gets me
Woot! Will remove tomorrow! Thanks for checking it out 🎊
I saw this somewhere |
@elizabeth-jimenez just a one-line way of doing:
|
Ahh |
…aPhase-Consulting/State-TalentMAP into chore/increase-test-coverage
Going to add a few more tests. Done