-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 component #321
Changes from 1 commit
f28ba81
cc969f1
a87bb2e
6eff245
3893a03
c01c4a6
23b3df4
80a2803
f3864ae
c2cbba0
ffc09a5
43deaf1
3d88988
c91d0d9
6fa9e5a
6937755
77baebb
25eb1bb
92c13d2
a44fb59
82b04fa
a9ce2e3
a299332
32b53d4
a6f0654
9edb4a0
ba14592
0f5235b
9398fa5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,29 @@ describe('Breadcrumb', () => { | |
.should.have.tagName('div') | ||
}) | ||
|
||
const sections = [ | ||
{ text: 'Home', link: true }, | ||
{ text: 'T-Shirt', href: 'google.com' }, | ||
] | ||
|
||
it('renders children with `sections` prop', () => { | ||
const sections = [ | ||
{ text: 'Home', link: true }, | ||
{ text: 'T-Shirt', href: 'google.com' }, | ||
] | ||
const wrapper = shallow(<Breadcrumb sections={sections} />) | ||
|
||
wrapper.find('BreadcrumbDivider').should.have.length(1) | ||
wrapper.find('BreadcrumbSection').should.have.length(2) | ||
}) | ||
|
||
it('renders defined divider with `divider` prop', () => { | ||
const wrapper = mount(<Breadcrumb sections={sections} divider='>' />) | ||
const divider = wrapper.find('BreadcrumbDivider').first() | ||
|
||
divider.text().should.to.equal('>') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use the chai-enzyme plugin. This allows us to move the enzyme method to the end of the assertion chain: -divider.text().should.to.equal('>')
+divider.should.contain.text('>') This makes for much more readable errors as well. Compare the assertion syntax here with the error messages: shallow(<Button>foo</Button>)
.text().should.equal('bar')
//=> expected 'foo' to equal 'bar' shallow(<Button>foo</Button>)
.should.contain.text('bar')
//=> expected <Button /> to contain text 'bar', but it has 'foo'
HTML:
<button type="button" class="ui button">foo</button> |
||
}) | ||
|
||
it('renders divider as `Icon` with `icon` prop', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since common.implementsIconProp(Breadcrumb) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const icon = mount(<Breadcrumb sections={sections} icon='right mangle' />).find('Icon') | ||
|
||
icon.should.have.class('right mangle') | ||
icon.should.have.tagName('i') | ||
}) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As noted in #321 (comment) let's use
chai-enzyme
assertions for much better assertions and error messages:Compare the difference in output between
should.have.length(x)
andshould.have.exactly(x).descendants(...)
: