import React from 'react';
import { shallow, mount } from 'enzyme';
import { PaginationLink } from '../';
describe('PaginationLink', () => {
it('should render default `a` tag when `href` is present', () => {
const wrapper = mount();
expect(wrapper.find('a').hostNodes().length).toBe(1);
});
it('should render default `button` tag when no `href` is present', () => {
const wrapper = mount();
expect(wrapper.find('button').hostNodes().length).toBe(1);
});
it('should render custom tag', () => {
const wrapper = mount();
expect(wrapper.find('span').hostNodes().length).toBe(1);
});
it('should render with "page-link" class', () => {
const wrapper = shallow();
expect(wrapper.hasClass('page-link')).toBe(true);
});
it('should render previous', () => {
const wrapper = shallow();
expect(wrapper.prop('aria-label')).toBe('Previous');
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('\u2039');
expect(wrapper.find('.sr-only').text()).toBe('Previous');
});
it('should render next', () => {
const wrapper = shallow();
expect(wrapper.prop('aria-label')).toBe('Next');
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('\u203A');
expect(wrapper.find('.sr-only').text()).toBe('Next');
});
it('should render default previous caret with children as an empty array', () => {
const wrapper = shallow();
expect(wrapper.prop('aria-label')).toBe('Previous');
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('\u2039');
expect(wrapper.find('.sr-only').text()).toBe('Previous');
});
it('should render default next caret with children as an empty array', () => {
const wrapper = shallow();
expect(wrapper.prop('aria-label')).toBe('Next');
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('\u203A');
expect(wrapper.find('.sr-only').text()).toBe('Next');
});
it('should render custom aria label', () => {
const wrapper = shallow();
expect(wrapper.prop('aria-label')).toBe('Yo');
expect(wrapper.find('.sr-only').text()).toBe('Yo');
});
it('should render custom caret specified as a string', () => {
const wrapper = shallow(Yo);
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('Yo');
});
it('should render custom caret specified as a component', () => {
const wrapper = shallow(Yo);
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('Yo');
});
it('should render first', () => {
const wrapper = shallow();
expect(wrapper.prop('aria-label')).toBe('First');
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('\u00ab');
expect(wrapper.find('.sr-only').text()).toBe('First');
});
it('should render last', () => {
const wrapper = shallow();
expect(wrapper.prop('aria-label')).toBe('Last');
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('\u00bb');
expect(wrapper.find('.sr-only').text()).toBe('Last');
});
it('should render default first caret with children as an empty array', () => {
const wrapper = shallow();
expect(wrapper.prop('aria-label')).toBe('First');
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('\u00ab');
expect(wrapper.find('.sr-only').text()).toBe('First');
});
it('should render default last caret with children as an empty array', () => {
const wrapper = shallow();
expect(wrapper.prop('aria-label')).toBe('Last');
expect(wrapper.find({ 'aria-hidden': 'true' }).text()).toBe('\u00bb');
expect(wrapper.find('.sr-only').text()).toBe('Last');
});
});