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

refactor(Rating): add rating icon component #640

Merged
merged 7 commits into from
Oct 9, 2016
Merged

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Oct 6, 2016

This PR:

  • splites Rating's icon to separate internal component;
  • updates docs to unified format;
  • minor refactors.

Copy link
Member

@levithomason levithomason left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -21,6 +23,9 @@ const _meta = {
},
}

/**
* A rating indicates user interest in content
* */
Copy link
Member

Choose a reason for hiding this comment

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

* */ => */

@layershifter
Copy link
Member Author

I'll update tests tomorrow, so we can merge it soon 👍

@codecov-io
Copy link

codecov-io commented Oct 7, 2016

Current coverage is 100% (diff: 100%)

Merging #640 into master will not change coverage

@@           master   #640   diff @@
====================================
  Files         131    132     +1   
  Lines        2098   2099     +1   
  Methods         0      0          
  Messages        0      0          
  Branches        0      0          
====================================
+ Hits         2098   2099     +1   
  Misses          0      0          
  Partials        0      0          

Powered by Codecov. Last update f561ce0...698cf25

@layershifter
Copy link
Member Author

I added tests for RatingIcon, it was easy.

I started updating of Rating tests for use RatingIcon instead of i.icon, but get stuck there. I added todos where test might be updated.

I don't understand how I can convert this to component test:

icons.find('.active').last().simulate('click')
icons.every('.icon.active')
  .should.equal(true, 'Some icon lost its "active" class')

If I correcty undestand enzyme docs, I can convert it to this?

icons.findWhere(n => prop('active', true)).last().simulate('click')
icons.everyWhere(n => prop('active', true))
  .should.equal(true, 'Some icon lost its "active" class')

@levithomason
Copy link
Member

You can also use the object property selector:

icons.find({ active: true })

@layershifter
Copy link
Member Author

You can also use the object property selector:

According to airbnb/enzyme/#582 - no, in mount mode, so I used findWhere there.

All tests are working with RatingIcon now, we're ready for final review there. Please, pay attension to Rating tests.

Copy link
Member

@levithomason levithomason left a comment

Choose a reason for hiding this comment

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

Looks good, let's just restore the test failure messages.

wrapper.should.not.have.className('selected')

icons.findWhere((i) => i.prop('selected', true))
.should.have.length(0)
Copy link
Member

Choose a reason for hiding this comment

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

Would prefer to keep the custom failure messages in these assertions. Otherwise, a failed test will just say Expected array to have length of 0, but it was X. Whereas, the custom message is more helpful Some icon did not remove its "selected" prop

icons.every('.icon.selected')
.should.equal(false, 'Some icon did not remove its "selected" class')
icons.findWhere(i => i.prop('selected', true))
.should.have.length(0)
Copy link
Member

Choose a reason for hiding this comment

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

Let's restore this failure message as well.

icons.every('.icon.active')
.should.equal(true, 'Some icon did not retain its "active" class')
icons.findWhere((i) => i.prop('active', true))
.should.have.length(5)
Copy link
Member

Choose a reason for hiding this comment

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

Another failure message to restore.

icons.every('.icon.active')
.should.equal(false, 'Some icon did not remove its "active" class')
icons.findWhere((i) => i.prop('active', true))
.should.have.length(0)
Copy link
Member

@levithomason levithomason Oct 8, 2016

Choose a reason for hiding this comment

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

Looks like there are a lot of these so I'll skip commenting on the rest! Though, let's update them all. Note, the last argument to any assertion is the custom failure message.

@layershifter
Copy link
Member Author

Restored messages to asserts and added some new. It's enought? Or I need add message to each assert?

@levithomason levithomason changed the title refactor(Rating): refactor component refactor(Rating): add rating icon component Oct 9, 2016
@levithomason levithomason merged commit 8bd788e into master Oct 9, 2016
@levithomason levithomason deleted the fix/rating branch October 9, 2016 21:41
@levithomason
Copy link
Member

Released in semantic-ui-react@0.55.1, thanks once again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants