Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
fix: remove usages of es6 from component and tests (#7)
Browse files Browse the repository at this point in the history
* Fixed a small polylint issue
  • Loading branch information
cecilia-sanare committed Oct 10, 2016
1 parent d7af748 commit 89dad1c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
18 changes: 13 additions & 5 deletions salte-rating.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,15 @@
type: Boolean,
value: false,
reflectToAttribute: true
}
},

/**
* The rating items displayed on the screen
*/
limitItems: {
type: Array,
readOnly: true
}
},

attached: function() {
Expand All @@ -125,15 +133,15 @@
* Renders the items based on the limit
*/
renderItems: function() {
let limitItems = [];
for (let i = 0; i < this.limit; i++) {
var limitItems = [];
for (var i = 0; i < this.limit; i++) {
limitItems.push(i);
}
this.set('limitItems', limitItems);
this._setLimitItems(limitItems);
},

_refreshRating: function(value) {
let items = Polymer.dom(this.root).querySelectorAll('.item-icon');
var items = Polymer.dom(this.root).querySelectorAll('.item-icon');
for (var i = 0; i < items.length; i++) {
items[i].style.width = Math.min(Math.max(value - i, 0), 1) * 100 + '%';
}
Expand Down
16 changes: 8 additions & 8 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@
</test-fixture>

<script>
describe('Basic features', function() {
suite('Basic features', function() {
var rating;

beforeEach(function() {
setup(function() {
rating = fixture('rating');
});

it('instantiating the element works', function() {
test('instantiating the element works', function() {
expect(rating.is).to.be.equal('salte-rating');
});

it('displays 5 rating items', function() {
test('displays 5 rating items', function() {
Polymer.dom.flush();

expect(Polymer.dom(rating.root).querySelectorAll('.item').length).to.be.equal(5);
});

it('displays 10 rating items', function(done) {
test('displays 10 rating items', function(done) {
Polymer.dom.flush();

rating.set('limit', 10);
Expand All @@ -49,7 +49,7 @@
});
});

it('updates width to display rating correctly', function() {
test('updates width to display rating correctly', function() {
Polymer.dom.flush();

rating.set('value', 1);
Expand All @@ -63,7 +63,7 @@
expect(icons[4].style.width).to.be.equal('0%');
});

it('updates width to display rating correctly - external value', function(done) {
test('updates width to display rating correctly - external value', function(done) {
rating.set('value', 2);
flush(function() {
var icons = Polymer.dom(rating.root).querySelectorAll('.item-icon');;
Expand All @@ -77,7 +77,7 @@
});
});

it('rate gets called when a rating item is clicked', function(done) {
test('rate gets called when a rating item is clicked', function(done) {
Polymer.dom.flush();

rating.addEventListener('rate', function(e) {
Expand Down

0 comments on commit 89dad1c

Please sign in to comment.