admin-on-rest-fr05t1k
Version:
A frontend Framework for building admin applications on top of REST services, using ES6, React and Material UI
41 lines (38 loc) • 1.93 kB
JavaScript
import assert from 'assert';
import React from 'react';
import { shallow } from 'enzyme';
import { Pagination } from './Pagination';
describe('<Pagination />', () => {
describe('mobile', () => {
it('should render a condensed <Toolbar>', () => {
const wrapper = shallow(<Pagination page={2} perPage={5} total={15} translate={x => x} width={1} />);
const iconButtons = wrapper.find('IconButton');
assert.equal(iconButtons.length, 2);
const flatButtons = wrapper.find('FlatButton');
assert.equal(flatButtons.length, 0);
});
it('should render only the text when no pagination is necessary', () => {
const wrapper = shallow(<Pagination page={1} perPage={20} total={15} translate={x => x} width={1} />);
const iconButtons = wrapper.find('IconButton');
assert.equal(iconButtons.length, 0);
const span = wrapper.find('span');
assert.equal(span.text(), 'aor.navigation.page_range_info');
});
});
describe('desktop', () => {
it('should render a normal <Toolbar>', () => {
const wrapper = shallow(<Pagination page={2} perPage={5} total={15} translate={x => x} width={2} />);
const iconButtons = wrapper.find('IconButton');
assert.equal(iconButtons.length, 0);
const flatButtons = wrapper.find('FlatButton');
assert.equal(flatButtons.length, 5);
});
it('should render only the text when no pagination is necessary', () => {
const wrapper = shallow(<Pagination page={1} perPage={20} total={15} translate={x => x} width={2} />);
const flatButtons = wrapper.find('FlatButton');
assert.equal(flatButtons.length, 0);
const span = wrapper.find('span');
assert.equal(span.text(), 'aor.navigation.page_range_info');
});
});
});