Fakultas Ilmu Komputer UI

Commit 0a936882 authored by emil farisan's avatar emil farisan
Browse files

added a few test case to editprofile.jsx

parent f8ff1f50
Pipeline #26733 failed with stages
in 6 minutes and 5 seconds
......@@ -49,4 +49,45 @@ describe('EditProfil', () => {
ReactTestUtils.Simulate.change(emailNode, { target: { value: password } });
expect(emailNode.value).to.equal(password);
});
it('check if the user data is set correctly', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
profile.getProfile().then(()=> expect(profile.props.route.own).to.equal(true));
const userData = Storage.getUserData();
expect(response2).to.equal(userData.student);
fetchMock.restore();
});
it('get student that doesnt exist', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: false, data: studentSession }} user={{ data: studentSession }} params={{ id: -1 }} />);
profile.getProfile().then(()=> expect(profile.state.name).to.equal('Gagal mendapatkan informasi'));
fetchMock.restore();
});
it('check if the date parser is working properly', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
birthDate = '1996-06-30'
parsedDate = profile.parseIndonesianDateFormat(birthDate)
expect(parsedDate).to.equal('30 Juni 1996')
fetchMock.restore();
});
it('check if the form is showing correctly', () => {
fetchMock.get('*', response2);
const profile = ReactTestUtils.renderIntoDocument(
<EditProfil route={{ own: true, data: studentSession }} user={{ data: studentSession }} params={{ id: 3 }} />);
profile.getProfile();
expect(profile.updateForm(false)).to.exist;
fetchMock.restore();
});
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment