Fakultas Ilmu Komputer UI

Commit d687ecd6 authored by EMIL's avatar EMIL
Browse files

Merge branch '1406568923-212' into 'master'

1406568923 212

See merge request !255
parents 4fa7e786 bfefc629
Pipeline #26747 passed with stages
in 18 minutes and 48 seconds
......@@ -2,6 +2,7 @@ import React from 'react';
import ReactTestUtils from 'react-dom/test-utils';
import fetchMock from 'fetch-mock';
import EditProfil from '../EditProfile';
import Storage from '../lib/Storage';
import { studentSession, response, response2 } from '../object/Response';
describe('EditProfil', () => {
......@@ -49,4 +50,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.get('user-data');
expect(userData.student).to.equal(null);
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 }} />);
const birthDate = '1996-06-30'
const 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