Permalink
Browse files

Unit Or Integration

  • Loading branch information...
toranb committed Feb 21, 2017
1 parent e18016b commit 20b2d35433458d2f4c2806eb2a64f8353791b923
Showing with 22 additions and 1 deletion.
  1. +1 −1 app/components/welp-rating/component.js
  2. +21 −0 tests/unit/components/welp-rating-test.js
@@ -19,7 +19,7 @@ var WelpRatingComponent = Ember.Component.extend({
</div>
`,
stars: [1, 2, 3, 4, 5],
- width: Ember.computed(function() {
+ width: Ember.computed('result.reviews', function() {
var reviews = this.get('result.reviews') || [];
var reviewed = reviews.filter((review) => {
return review.reviewed ? review : undefined;
@@ -101,3 +101,24 @@ test('width is htmlSafe', function(assert) {
let width = subject.get('width');
assert.ok(width instanceof Ember.Handlebars.SafeString);
});
+
+test('toran width will recompute when reviews are added', function(assert) {
+ let subject = this.subject({
+ result: {
+ id: 1,
+ reviews: [{id: 2, rating: 3}]
+ }
+ });
+ let width = subject.get('width');
+ assert.equal(width.toString(), 'width: 0%');
+
+ Ember.run(() => {
+ subject.set('result.reviews', [
+ {id: 2, rating: 3},
+ {id: 3, rating: 5, reviewed: true}
+ ]);
+ });
+
+ width = subject.get('width');
+ assert.equal(width.toString(), 'width: 100%');
+});

0 comments on commit 20b2d35

Please sign in to comment.