-
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
refactor(Rating): add rating icon component #640
Conversation
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.
LGTM!
@@ -21,6 +23,9 @@ const _meta = { | |||
}, | |||
} | |||
|
|||
/** | |||
* A rating indicates user interest in content | |||
* */ |
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.
* */
=> */
I'll update tests tomorrow, so we can merge it soon 👍 |
Current coverage is 100% (diff: 100%)@@ 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
|
I added tests for I started updating of 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') |
You can also use the object property selector: icons.find({ active: true }) |
According to airbnb/enzyme/#582 - no, in All tests are working with |
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.
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) |
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.
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) |
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.
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) |
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.
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) |
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.
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.
Restored messages to asserts and added some new. It's enought? Or I need add message to each assert? |
Released in |
This PR:
Rating
's icon to separate internal component;