Skip to content

Commit

Permalink
Merge branch 'develop' into tests--description-list
Browse files Browse the repository at this point in the history
  • Loading branch information
lsprr committed Feb 27, 2024
2 parents d39f43d + 3f874c4 commit 32ff562
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
14 changes: 0 additions & 14 deletions packages/react/__tests__/src/components/Line/index.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
import React, { createRef } from 'react';
import { shallow } from 'enzyme';
import {
default as Breadcrumb,
BreadcrumbLink,
BreadcrumbItem
} from 'src/components/Breadcrumb';
import axe from '../../../axe';
import React from 'react';
import { render, screen } from '@testing-library/react';
import Breadcrumb, { BreadcrumbLink, BreadcrumbItem } from './';
import axe from '../../axe';

test('should render breadcrumbs', () => {
const breadcrumb = shallow(
render(
<Breadcrumb aria-label="breadcrumb">
<BreadcrumbLink href="#">one</BreadcrumbLink>
<BreadcrumbLink href="#">two</BreadcrumbLink>
<BreadcrumbItem>three</BreadcrumbItem>
</Breadcrumb>
);
expect(breadcrumb.hasClass('Breadcrumb')).toBe(true);
expect(breadcrumb.find('li').length).toBe(3);
expect(
screen.getByRole('navigation', { name: 'breadcrumb' })
).toBeInTheDocument();
expect(screen.queryAllByRole('listitem')).toHaveLength(3);
});

test('should render separators between breadcrumbs', () => {
const breadcrumb = shallow(
render(
<Breadcrumb aria-label="breadcrumb">
<BreadcrumbLink href="#">one</BreadcrumbLink>
<BreadcrumbLink href="#">two</BreadcrumbLink>
<BreadcrumbItem>three</BreadcrumbItem>
</Breadcrumb>
);
expect(breadcrumb.find('.Breadcrumb__Separator').length).toBe(2);
expect(
breadcrumb
.find(BreadcrumbItem)
.find('.Breadcrumb__Separator')
.exists()
).toBeFalsy();
screen.getByRole('navigation', { name: 'breadcrumb' })
).toHaveTextContent('one/two/three');
});

test('should render custom separators between breadcrumbs', () => {
const breadcrumb = shallow(
render(
<Breadcrumb aria-label="breadcrumb" separator="💩">
<BreadcrumbLink href="#">one</BreadcrumbLink>
<BreadcrumbLink href="#">two</BreadcrumbLink>
<BreadcrumbItem>three</BreadcrumbItem>
</Breadcrumb>
);
expect(breadcrumb.text()).toEqual('one💩two💩three');
expect(
screen.getByRole('navigation', { name: 'breadcrumb' })
).toHaveTextContent('one💩two💩three');
});

test('should return no axe violations', async () => {
const breadcrumb = shallow(
render(
<Breadcrumb aria-label="breadcrumb">
<BreadcrumbLink href="#">one</BreadcrumbLink>
<BreadcrumbLink href="#">two</BreadcrumbLink>
<BreadcrumbItem>three</BreadcrumbItem>
</Breadcrumb>
);

expect(await axe(breadcrumb.html())).toHaveNoViolations();
const results = await axe(
screen.getByRole('navigation', { name: 'breadcrumb' })
);
expect(results).toHaveNoViolations();
});
16 changes: 16 additions & 0 deletions packages/react/src/components/Line/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { render } from '@testing-library/react';
import Line from './index';
import axe from '../../axe';

test('passes classNames through', () => {
const { container } = render(<Line className="baz" />);
expect(container.firstChild).toHaveClass('Line', 'baz');
});

test('should return no axe violations', async () => {
const { container } = render(<Line />);

const results = await axe(container);
expect(results).toHaveNoViolations();
});

0 comments on commit 32ff562

Please sign in to comment.