Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
Kape
Commits
d687ecd6
Commit
d687ecd6
authored
Dec 06, 2019
by
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
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
assets/js/__test__/EditProfile-test.jsx
View file @
d687ecd6
...
@@ -2,6 +2,7 @@ import React from 'react';
...
@@ -2,6 +2,7 @@ import React from 'react';
import
ReactTestUtils
from
'
react-dom/test-utils
'
;
import
ReactTestUtils
from
'
react-dom/test-utils
'
;
import
fetchMock
from
'
fetch-mock
'
;
import
fetchMock
from
'
fetch-mock
'
;
import
EditProfil
from
'
../EditProfile
'
;
import
EditProfil
from
'
../EditProfile
'
;
import
Storage
from
'
../lib/Storage
'
;
import
{
studentSession
,
response
,
response2
}
from
'
../object/Response
'
;
import
{
studentSession
,
response
,
response2
}
from
'
../object/Response
'
;
describe
(
'
EditProfil
'
,
()
=>
{
describe
(
'
EditProfil
'
,
()
=>
{
...
@@ -49,4 +50,45 @@ describe('EditProfil', () => {
...
@@ -49,4 +50,45 @@ describe('EditProfil', () => {
ReactTestUtils
.
Simulate
.
change
(
emailNode
,
{
target
:
{
value
:
password
}
});
ReactTestUtils
.
Simulate
.
change
(
emailNode
,
{
target
:
{
value
:
password
}
});
expect
(
emailNode
.
value
).
to
.
equal
(
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
();
});
});
});
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment