Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Fasilkom UI Open Source Software
Kape
Commits
3345a9cb
Commit
3345a9cb
authored
Apr 09, 2017
by
Zamil Majdy
Browse files
[#140655219] #20 Add test on new library methods
parent
dfc575b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
assets/js/__test__/lib/Server-test.jsx
View file @
3345a9cb
...
...
@@ -94,6 +94,11 @@ describe('Server get test', () => {
Server
.
sendRequest
(
'
/test
'
,
'
GET
'
,
{},
true
).
then
((
data
)
=>
{
expect
(
data
).
to
.
exist
;
});
});
it
(
'
Check submit method
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
{
hue
:
"
hue
"
,
hui
:
"
hui
"
});
Server
.
submit
(
'
/test
'
,
{},
'
GET
'
,
true
).
then
((
data
)
=>
{
expect
(
data
).
to
.
exist
;
});
});
it
(
'
Check isloggedin method
'
,
()
=>
{
expect
(
Server
.
isLoggedIn
()).
to
.
not
.
exist
;
});
...
...
assets/js/__test__/lib/Storage-test.jsx
View file @
3345a9cb
/* eslint-disable
no-unused-expressions
*/
/* eslint-disable */
import
Storage
from
'
./../../lib/Storage
'
;
describe
(
'
Storage get key
'
,
()
=>
{
...
...
@@ -30,4 +30,21 @@ describe('Storage clear key', () => {
expect
(
Storage
.
clear
()).
to
.
be
.
not
.
exist
;
expect
(
Storage
.
get
(
'
test
'
)).
to
.
be
.
not
.
exist
;
});
});
\ No newline at end of file
});
describe
(
'
Storage getUserData test
'
,
()
=>
{
const
fetchMock
=
require
(
'
fetch-mock
'
);
it
(
'
Check Storage when there is no userdata
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
'
hue
'
);
Storage
.
set
(
'
user-data
'
,
null
);
// clear to make sure storage empty
expect
(
Storage
.
get
(
'
user-data
'
)).
to
.
equal
(
null
);
Storage
.
getUserData
().
then
(
r
=>
{
expect
(
r
).
to
.
equal
(
'
hue
'
);});
// Storage call
});
it
(
'
Check Storage when there is already userdata
'
,
()
=>
{
Storage
.
set
(
'
user-data
'
,
'
hue
'
);
// set to make sure storage not empty
Storage
.
getUserData
().
then
(
r
=>
{
expect
(
r
).
to
.
equal
(
'
hue
'
);});
});
});
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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