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
93537587
Commit
93537587
authored
May 03, 2017
by
M. Reza Qorib
Browse files
[#144502159] [Red] #37 create test for Pagination component
parent
99f4e825
Changes
1
Hide whitespace changes
Inline
Side-by-side
assets/js/__test__/components/Pagination-test.jsx
0 → 100644
View file @
93537587
/* eslint-disable no-unused-expressions */
import
React
from
'
react
'
;
import
ReactTestUtils
from
'
react-addons-test-utils
'
;
import
fetchMock
from
'
fetch-mock
'
;
import
List
from
'
../../components/Pagination
'
import
VacancyList
from
'
../../components/VacancyList
'
describe
(
'
Pagination
'
,
()
=>
{
const
response
=
[{
close_time
:
'
2019-03-28T05:55:42Z
'
,
company
:
{
address
:
'
kebayoran baru
'
,
id
:
1
,
logo
:
null
,
name
:
'
tutup lapak
'
,
},
created
:
'
2017-03-28T07:05:47.128672Z
'
,
description
:
'
Lorem ipsum dolbh.
'
,
id
:
1
,
name
:
'
Software Engineer
'
,
open_time
:
'
2017-03-28T05:55:38Z
'
,
updated
:
'
2017-03-28T07:34:13.122093Z
'
,
verified
:
true
,
},
{
close_time
:
'
2019-03-28T05:55:42Z
'
,
company
:
{
address
:
'
kebayoran baru
'
,
id
:
2
,
logo
:
null
,
name
:
'
tutup lapak
'
,
},
created
:
'
2017-03-28T07:05:47.128672Z
'
,
description
:
'
Lorem ipsum dolbh.
'
,
id
:
2
,
name
:
'
Software Engineer
'
,
open_time
:
'
2017-03-28T05:55:38Z
'
,
updated
:
'
2017-03-28T07:34:13.122093Z
'
,
verified
:
true
,
}];
const
response2
=
[{
close_time
:
'
2019-03-28T05:55:42Z
'
,
company
:
{
address
:
'
kebayoran baru
'
,
id
:
1
,
logo
:
null
,
name
:
'
tutup lapak
'
,
},
created
:
'
2017-03-28T07:05:47.128672Z
'
,
description
:
'
Lorem ipsum dolbh.
'
,
id
:
2
,
name
:
'
Software Engineer
'
,
open_time
:
'
2017-03-28T05:55:38Z
'
,
updated
:
'
2017-03-28T07:34:13.122093Z
'
,
verified
:
true
,
}];
it
(
'
renders without problem
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
const
pagination
=
ReactTestUtils
.
renderIntoDocument
(
<
Pagination
child
=
{
<
div
/>
}
url
=
"test"
/>);
expect
(
pagination
).
to
.
exist
;
fetchMock
.
restore
();
});
it
(
'
get items without problem
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
const
pagination
=
ReactTestUtils
.
renderIntoDocument
(
<
Pagination
child
=
{
<
div
/>
}
url
=
"test"
/>);
pagination
.
getItemsData
();
expect
(
pagination
.
state
.
items
).
to
.
equal
(
response
);
fetchMock
.
restore
();
});
it
(
'
generate child components without problem
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
response
);
const
child
=
<
VacancyList
url
=
""
userId
=
""
/>
const
pagination
=
ReactTestUtils
.
renderIntoDocument
(
<
Pagination
child
=
{
child
}
url
=
"test"
/>);
const
childRendered
=
ReactTestUtils
.
findRenderedDOMComponentWithTag
(
pagination
,
child
);
expect
(
childRendered
).
to
,
exist
;
fetchMock
.
restore
();
});
it
(
'
renders without problem when failed getting data
'
,
()
=>
{
fetchMock
.
get
(
'
*
'
,
400
);
const
pagination
=
ReactTestUtils
.
renderIntoDocument
(
<
Pagination
child
=
{
<
div
/>
}
url
=
"test"
/>);
expect
(
pagination
).
to
.
exist
;
fetchMock
.
restore
();
});
});
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