import React from 'react';
import { render, cleanup } from '@testing-library/react';
import { NavLink } from 'reactstrap';
import Breadcrumbs, { Crumb } from '..';
afterEach(cleanup);
describe('Breadcrumbs', () => {
test('should render', () => {
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
test('should render child as current page', () => {
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
test('should render crumbs', () => {
const crumbs: Crumb[] = [
{
name: 'my grand parent page',
url: '/parent-page',
},
{
name: 'my parent page',
url: '/grand-parent-page',
},
];
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
test('should render crumbs with missing values', () => {
const crumbs: Crumb[] = [
{
name: 'my grand parent page',
url: '/parent-page',
},
{
name: '',
url: '',
},
];
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
test('should render custom ellipse', () => {
const crumbs: Crumb[] = [
{
name: '',
url: '',
},
];
const { container } = render();
expect(container.firstChild).toMatchSnapshot();
});
test('should render custom home url', () => {
const { getByText } = render();
const homeBtn = getByText('Home');
expect(homeBtn.getAttribute('href')).toBe('/go-home');
});
test('should render custom link tag', () => {
const { getByText } = render();
const homeBtn = getByText('Home');
expect(homeBtn.className).toBe('nav-link');
});
});