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 component #321

Merged
merged 29 commits into from
Jul 17, 2016
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f28ba81
Breadcrumb component
Jul 2, 2016
cc969f1
Breadcrumb.Section #321
Jul 5, 2016
a87bb2e
Breadcrumb.Section #321
Jul 5, 2016
6eff245
Merge branch 'master' of https://github.com/TechnologyAdvice/stardust…
layershifter Jul 5, 2016
3893a03
README.md update #321
layershifter Jul 5, 2016
c01c4a6
(refactor) Breadcrumb.Section #321
layershifter Jul 5, 2016
23b3df4
(fix) Breadcrumb.Section test #321
layershifter Jul 5, 2016
80a2803
(fix) Breadcrumb.Section #321
layershifter Jul 5, 2016
f3864ae
(fix) Breadcrumb.Section #321
Jul 6, 2016
c2cbba0
(feat) Breadcrumb.Section #321
Jul 6, 2016
ffc09a5
(fix) Breadcrumb.Divider #321
Jul 6, 2016
43deaf1
Merge branch 'master' of https://github.com/TechnologyAdvice/stardust…
Jul 6, 2016
3d88988
(feat) Breadcrumb #321
Jul 6, 2016
c91d0d9
(fix) Breadcrumb.Section test #321
layershifter Jul 6, 2016
6fa9e5a
(fix) Breadcrumb.Section test #321
layershifter Jul 6, 2016
6937755
(fix) Breadcrumb #321
layershifter Jul 6, 2016
77baebb
(feat) Breadcrumb #321
Jul 7, 2016
25eb1bb
Merge branch 'master' of https://github.com/TechnologyAdvice/stardust…
Jul 7, 2016
92c13d2
(fix) Breadcrumb key #321
layershifter Jul 7, 2016
a44fb59
(feat) Breadcrumb test #321
layershifter Jul 7, 2016
82b04fa
(feat) Breadcrumb tests #321
Jul 8, 2016
a9ce2e3
(feat) Breadcrumb docs #321
Jul 8, 2016
a299332
(fix) Breadcrumb docs #321
Jul 11, 2016
32b53d4
(fix) Breadcrumb #321
Jul 11, 2016
a6f0654
Merge branch 'master' of https://github.com/TechnologyAdvice/stardust…
Jul 15, 2016
9edb4a0
(fix) Breadcrumb docs
Jul 15, 2016
ba14592
(fix) Breadcrumb
Jul 15, 2016
0f5235b
Merge branch 'master' of https://github.com/TechnologyAdvice/stardust…
layershifter Jul 17, 2016
9398fa5
(Breadcrumb) Test update
layershifter Jul 17, 2016
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
23 changes: 19 additions & 4 deletions test/specs/collections/Breadcrumb/Breadcrumb-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Member

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:

-wrapper.find('BreadcrumbDivider').should.have.length(1)
+wrapper.should.have.exactly(1).descendants('BreadcrumbDivider')
-wrapper.find('BreadcrumbSection').should.have.length(2)
+wrapper.should.have.exactly(2).descendants('BreadcrumbSection')

Compare the difference in output between should.have.length(x) and should.have.exactly(x).descendants(...):

shallow(<Textarea />)
  .find('textarea').should.have.length(2)

//=> expected { Object (component, root, ...) } to have a length of 2 but got 1
shallow(<Textarea />)
  .should.have.have.exactly(2).descendants('textarea')

//=> expected <Textarea /> to have 2 descendants 'textarea' but actually found 1

         HTML:

         <textarea data-reactroot=""></textarea>

})

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('>')
Copy link
Member

Choose a reason for hiding this comment

The 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', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since icon and image props should behave consistently across the entire project, there is a common tests for them. You can remove this test and replace it with:

common.implementsIconProp(Breadcrumb)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried, but seems it's not solution. Breadcrumb will not become <i> with prop.

_287

const icon = mount(<Breadcrumb sections={sections} icon='right mangle' />).find('Icon')

icon.should.have.class('right mangle')
icon.should.have.tagName('i')
})
})