Skip to content

Commit

Permalink
Lint the tests
Browse files Browse the repository at this point in the history
Also, fix all the lint errors in the tests
  • Loading branch information
dfreedm committed Feb 12, 2016
1 parent a4cc272 commit e5063ca
Show file tree
Hide file tree
Showing 35 changed files with 477 additions and 456 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules/*
bower_components/*
test/*
src/**/demo/*
src/**/experimental/*
2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ gulp.task('release', function(cb) {
});

gulp.task('lint', function() {
return gulp.src('src/**/*.html')
return gulp.src(['src/**/*.html', 'test/unit/*.html'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
Expand Down
3 changes: 3 additions & 0 deletions test/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
assets/*
compat/*
smoke/*
10 changes: 10 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"env": {
"mocha": true
},
"globals": {
"assert": true,
"sinon": true,
"WCT": true
}
}
16 changes: 8 additions & 8 deletions test/unit/array-selector.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
</template>

<script>
/* global bind observer singleBound multiBound */
suite('basic', function() {

test('single selection', function() {
var el = singleConfigured;
var el = document.querySelector('#singleConfigured');
// Nothing selected
assert.strictEqual(el.selectedItem, null);
assert.isFalse(el.isSelected(el.items[0]));
Expand Down Expand Up @@ -76,7 +76,7 @@
});

test('multiple selection', function() {
var el = multiConfigured;
var el = document.querySelector('#multiConfigured');
// Nothing selected
assert.sameMembers(el.selected, []);
assert.isFalse(el.isSelected(el.items[0]));
Expand Down Expand Up @@ -143,7 +143,7 @@
};
singleBound.select(bind.items[2]);
assert.equal(called, true);
observer.singleChanged = function(info) {};
observer.singleChanged = function() {};
});

test('single selection sub-property change', function() {
Expand All @@ -156,7 +156,7 @@
};
bind.set(['items', 2, 'name'], 'test');
assert.equal(called, true);
observer.singleChanged = function(info) {};
observer.singleChanged = function() {};
});

test('single selection sub-property change after unshift', function() {
Expand All @@ -170,7 +170,7 @@
bind.unshift('items', {name: 'zero'});
bind.set(['items', 3, 'name'], 'test2');
assert.equal(called, true);
observer.singleChanged = function(info) {};
observer.singleChanged = function() {};
});

test('multi selection notification', function() {
Expand Down Expand Up @@ -210,7 +210,7 @@
};
multiBound.select(bind.items[0]);
assert.equal(called, true);
observer.multiChanged = function(info) {};
observer.multiChanged = function() {};
});

test('multi selection sub-property change', function() {
Expand All @@ -230,7 +230,7 @@
};
bind.set(['items', 0, 'name'], 'test2');
assert.equal(called, true);
observer.multiChanged = function(info) {};
observer.multiChanged = function() {};
});


Expand Down
6 changes: 3 additions & 3 deletions test/unit/async.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<body>

<script>

/* global Async */
setup(function() {
window.Async = Polymer.Async;
});
Expand Down Expand Up @@ -191,7 +191,7 @@
called3++;
};
var h1 = Async.run(callback1);
var h2 = Async.run(callback2);
var h2 = Async.run(callback2); //eslint-disable-line no-unused-vars
var h3 = Async.run(callback3);
Async.cancel(h1);
Async.cancel(h3);
Expand Down Expand Up @@ -306,7 +306,7 @@
called3++;
};
var h1 = Async.run(callback1, 50);
var h2 = Async.run(callback2, 50);
var h2 = Async.run(callback2, 50); //eslint-disable-line no-unused-vars
var h3 = Async.run(callback3, 200);
Async.cancel(h1);
Async.cancel(h3);
Expand Down
64 changes: 32 additions & 32 deletions test/unit/attached-style-elements.html
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<dom-module id="attached-style">
<style>
:host {
display: block;
box-sizing: border-box;
border: 1px solid black;
height: 100px;
}
</style>
<template>Hi</template>
<script>
Polymer({

is: 'attached-style',

attached: function() {
this.offsetParentAtAttachedTime = this.offsetParent;
this.offsetHeightAtAttachedTime = this.offsetHeight;
}

});
</script>
</dom-module>
<!--
@license
Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
-->
<dom-module id="attached-style">
<style>
:host {
display: block;
box-sizing: border-box;
border: 1px solid black;
height: 100px;
}
</style>
<template>Hi</template>
<script>
Polymer({

is: 'attached-style',

attached: function() {
this.offsetParentAtAttachedTime = this.offsetParent;
this.offsetHeightAtAttachedTime = this.offsetHeight;
}

});
</script>
</dom-module>
8 changes: 4 additions & 4 deletions test/unit/attributes-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@
propChangedCount: 0,
attr1ChangedCount: 0,

propChanged: function(prop) {
propChanged: function() {
this.propChangedCount++;
},

attr1Changed: function(prop) {
attr1Changed: function() {
this.attr1ChangedCount++;
}

});
</script>

Expand Down Expand Up @@ -154,4 +154,4 @@
this.setAttribute('prop2', 'hi');
}
});
</script>
</script>
1 change: 1 addition & 0 deletions test/unit/attributes.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
</x-reflect>

<script>
/* global basicDefault basicConfigured compose reflectDefault reflectConfigured */

var configuredObject = {foo: 'bar', nested: {'meaning': 42}, arr: [0, 'foo', true]};
var configuredArray = [0, 'foo', true, {foo: 'bar'}];
Expand Down
1 change: 1 addition & 0 deletions test/unit/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

setup(function() {
// Ensure a clean environment for each test.
/* global Base */
window.Base = Polymer.Base;
window.Child = Object.create(Base);
Child._registerFeatures = function() {};
Expand Down
4 changes: 2 additions & 2 deletions test/unit/behaviors-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

overridablePropertyB: {
value: true
},
}

},

Expand All @@ -102,7 +102,7 @@
_simpleProperty: 'B',

_disabledChanged: function(disabled) {
this.__disabled = disabled
this.__disabled = disabled;
},

ready: function() {
Expand Down
8 changes: 4 additions & 4 deletions test/unit/bind.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@

test('NaN does not loop observers', function() {
el.clearObserverCounts();
el.addEventListener('notifierwithoutcomputing-changed', function(e) {
el.addEventListener('notifierwithoutcomputing-changed', function() {
if (el.observerCounts.notifierWithoutComputingChanged >= 3) {
throw new Error('infinite loop!');
}
Expand All @@ -155,7 +155,7 @@

test('computed property with multiple dependencies', function() {
var notified = 0;
el.addEventListener('computed-from-multiple-values-changed', function(e) {
el.addEventListener('computed-from-multiple-values-changed', function() {
notified++;
});
el.sum1 = 10;
Expand Down Expand Up @@ -195,7 +195,7 @@

test('no read-only notification sent with assignment', function() {
var notified = 0;
el.addEventListener('readonlyvalue-changed', function(e) {
el.addEventListener('readonlyvalue-changed', function() {
notified++;
});
el.readonlyvalue = 47;
Expand Down Expand Up @@ -663,7 +663,7 @@
suite('warnings', function() {

var el;
var warn;
var warn; //eslint-disable-line no-unused-vars

setup(function() {
el = document.createElement('x-basic');
Expand Down
4 changes: 2 additions & 2 deletions test/unit/configure-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
value: 5
},
attrValue: {
value: 'attrValue',
value: 'attrValue'
},
attrNumber: {
value: '42'
Expand All @@ -181,4 +181,4 @@

});
</script>
</dom-module>
</dom-module>
Loading

0 comments on commit e5063ca

Please sign in to comment.