Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Breadcrumb.Item component to replace Breadcrumb items prop #293

Merged
merged 3 commits into from
Feb 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Breadcrumb component Breadcrumb.Item component should have is-active class 1`] = `
<li
className="is-active"
>
active item
</li>
`;

exports[`Breadcrumb component Breadcrumb.Item component should render <li> 1`] = `
<li>
item
</li>
`;

exports[`Breadcrumb component Should be a Breadcrumb 1`] = `
<nav
className="breadcrumb"
>
<ul>
<li
className=""
>
<li>
<a
href="/"
>
Home
</a>
</li>
<li
className=""
>
<li>
<a
href="/section"
>
Section
</a>
</li>
<li
className="is-active"
>
<li>
<a
href="/detail"
>
Expand All @@ -46,18 +54,14 @@ exports[`Breadcrumb component Should use inline style and custom size 1`] = `
}
>
<ul>
<li
className=""
>
<li>
<a
href="/"
>
Home
</a>
</li>
<li
className=""
>
<li>
<a
href="/section"
>
Expand All @@ -82,27 +86,21 @@ exports[`Breadcrumb component should use separator arrow 1`] = `
className="breadcrumb has-arrow-separator"
>
<ul>
<li
className=""
>
<li>
<a
href="#1"
>
Storybook
</a>
</li>
<li
className=""
>
<li>
<a
href="#2"
>
Breadcrumb
</a>
</li>
<li
className="is-active"
>
<li>
<a
href="#3"
>
Expand All @@ -118,27 +116,21 @@ exports[`Breadcrumb component should use separator bullet 1`] = `
className="breadcrumb has-bullet-separator"
>
<ul>
<li
className=""
>
<li>
<a
href="#1"
>
Storybook
</a>
</li>
<li
className=""
>
<li>
<a
href="#2"
>
Breadcrumb
</a>
</li>
<li
className="is-active"
>
<li>
<a
href="#3"
>
Expand All @@ -154,27 +146,21 @@ exports[`Breadcrumb component should use separator dot 1`] = `
className="breadcrumb has-dot-separator"
>
<ul>
<li
className=""
>
<li>
<a
href="#1"
>
Storybook
</a>
</li>
<li
className=""
>
<li>
<a
href="#2"
>
Breadcrumb
</a>
</li>
<li
className="is-active"
>
<li>
<a
href="#3"
>
Expand All @@ -190,27 +176,21 @@ exports[`Breadcrumb component should use separator null 1`] = `
className="breadcrumb"
>
<ul>
<li
className=""
>
<li>
<a
href="#1"
>
Storybook
</a>
</li>
<li
className=""
>
<li>
<a
href="#2"
>
Breadcrumb
</a>
</li>
<li
className="is-active"
>
<li>
<a
href="#3"
>
Expand All @@ -226,27 +206,21 @@ exports[`Breadcrumb component should use separator succeeds 1`] = `
className="breadcrumb has-succeeds-separator"
>
<ul>
<li
className=""
>
<li>
<a
href="#1"
>
Storybook
</a>
</li>
<li
className=""
>
<li>
<a
href="#2"
>
Breadcrumb
</a>
</li>
<li
className="is-active"
>
<li>
<a
href="#3"
>
Expand Down
107 changes: 52 additions & 55 deletions src/components/breadcrumb/__test__/breadcrumb.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,74 +3,71 @@ import renderer from 'react-test-renderer';
import Breadcrumb from '..';

describe('Breadcrumb component', () => {
describe('Breadcrumb.Item component', () => {
it('should render <li>', () => {
const component = renderer.create(
<Breadcrumb.Item>item</Breadcrumb.Item>,
);
expect(component.toJSON()).toMatchSnapshot();
});

it('should have is-active class', () => {
const component = renderer.create(
<Breadcrumb.Item active>active item</Breadcrumb.Item>,
);
expect(component.toJSON()).toMatchSnapshot();
});
});

it('Should be a Breadcrumb', () => {
const component = renderer.create(
<Breadcrumb
items={[
{
url: '/',
name: 'Home',
},
{
url: '/section',
name: 'Section',
},
{
url: '/detail',
name: 'Details',
active: true,
},
]}
/>,
<Breadcrumb>
<Breadcrumb.Item>
<a href="/">Home</a>
</Breadcrumb.Item>
<Breadcrumb.Item>
<a href="/section">Section</a>
</Breadcrumb.Item>
<Breadcrumb.Item>
<a href="/detail">Details</a>
</Breadcrumb.Item>
</Breadcrumb>,
);
expect(component.toJSON()).toMatchSnapshot();
});
[null, 'arrow', 'dot', 'bullet', 'succeeds'].map(separator =>

[null, 'arrow', 'dot', 'bullet', 'succeeds'].map((separator) =>
it(`should use separator ${separator}`, () => {
const component = renderer.create(
<Breadcrumb
separator={separator}
items={[
{
name: 'Storybook',
url: '#1',
},
{
name: 'Breadcrumb',
url: '#2',
},
{
name: 'Breadcrumb Types',
url: '#3',
active: true,
},
]}
/>,
<Breadcrumb separator={separator}>
<Breadcrumb.Item>
<a href="#1">Storybook</a>
</Breadcrumb.Item>
<Breadcrumb.Item>
<a href="#2">Breadcrumb</a>
</Breadcrumb.Item>
<Breadcrumb.Item>
<a href="#3">Breadcrumb Types</a>
</Breadcrumb.Item>
</Breadcrumb>,
);
expect(component.toJSON()).toMatchSnapshot();
}),
);

it('Should use inline style and custom size', () => {
const component = renderer.create(
<Breadcrumb
style={{ marginTop: 10 }}
size="large"
items={[
{
url: '/',
name: 'Home',
},
{
url: '/section',
name: 'Section',
},
{
url: '/detail',
name: 'Details',
active: true,
},
]}
/>,
<Breadcrumb style={{ marginTop: 10 }} size="large">
<Breadcrumb.Item>
<a href="/">Home</a>
</Breadcrumb.Item>
<Breadcrumb.Item>
<a href="/section">Section</a>
</Breadcrumb.Item>
<Breadcrumb.Item active>
<a href="/detail">Details</a>
</Breadcrumb.Item>
</Breadcrumb>,
);
expect(component.toJSON()).toMatchSnapshot();
});
Expand Down
Loading