Fakultas Ilmu Komputer UI

Commit 93537587 authored by M. Reza Qorib's avatar M. Reza Qorib
Browse files

[#144502159] [Red] #37 create test for Pagination component

parent 99f4e825
/* 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();
});
});
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