Skip to content

Commit

Permalink
Merge pull request #4769 from Polymer/tooling-cleanup
Browse files Browse the repository at this point in the history
Test cleanup for tooling
  • Loading branch information
dfreedm authored Aug 8, 2017
2 parents 9b00efa + 4095e12 commit 3fd628c
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 93 deletions.
9 changes: 4 additions & 5 deletions lib/utils/gestures.html
Original file line number Diff line number Diff line change
Expand Up @@ -337,19 +337,18 @@
if (handled.skip) {
return;
}
let recognizers = Gestures.recognizers;
// reset recognizer state
for (let i = 0, r; i < recognizers.length; i++) {
r = recognizers[i];
for (let i = 0, r; i < Gestures.recognizers.length; i++) {
r = Gestures.recognizers[i];
if (gs[r.name] && !handled[r.name]) {
if (r.flow && r.flow.start.indexOf(ev.type) > -1 && r.reset) {
r.reset();
}
}
}
// enforce gesture recognizer order
for (let i = 0, r; i < recognizers.length; i++) {
r = recognizers[i];
for (let i = 0, r; i < Gestures.recognizers.length; i++) {
r = Gestures.recognizers[i];
if (gs[r.name] && !handled[r.name]) {
handled[r.name] = true;
r[type](ev);
Expand Down
13 changes: 6 additions & 7 deletions test/unit/async.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
<head>
<meta charset="utf-8">
<script src="../../../webcomponentsjs/webcomponents-lite.js"></script>
<script>
<script src="../../../web-component-tester/browser.js"></script>
<link rel="import" href="../../lib/utils/async.html">
</head>
<body>

<script>
var capturedErrors = [];
var captureEnabled = false;
window.addEventListener('error', function(e) {
Expand All @@ -23,13 +28,7 @@
return true;
}
});
</script>
<script src="../../../web-component-tester/browser.js"></script>
<link rel="import" href="../../lib/utils/async.html">
</head>
<body>

<script>
suite('Queueing micro tasks', function() {

test('The queued function runs.', function(done) {
Expand Down
36 changes: 18 additions & 18 deletions test/unit/behaviors.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<script>
HTMLImports.whenReady(function() {
Polymer.BehaviorA = {
window.BehaviorA = {
properties: {

label: {
Expand Down Expand Up @@ -87,7 +87,7 @@
}
};

Polymer.BehaviorB = {
window.BehaviorB = {
properties: {

disabled: {
Expand Down Expand Up @@ -136,7 +136,7 @@
},
};

Polymer.BehaviorC = {
window.BehaviorC = {

properties: {

Expand All @@ -149,7 +149,7 @@
_simpleProperty: 'C'
};

Polymer.BehaviorD = {
window.BehaviorD = {

properties: {

Expand All @@ -166,7 +166,7 @@
is: 'single-behavior',

behaviors: [
Polymer.BehaviorA
window.BehaviorA
],

properties: {},
Expand All @@ -179,8 +179,8 @@
is: 'multi-behaviors',

behaviors: [
Polymer.BehaviorA,
Polymer.BehaviorB
window.BehaviorA,
window.BehaviorB
],

hostAttributes: {
Expand Down Expand Up @@ -211,12 +211,12 @@
is: 'nested-behaviors',

behaviors: [
[Polymer.BehaviorB, [Polymer.BehaviorC, Polymer.BehaviorB], Polymer.BehaviorA],
[Polymer.BehaviorD]
[window.BehaviorB, [window.BehaviorC, window.BehaviorB], window.BehaviorA],
[window.BehaviorD]
]
});

Polymer.registerBehavior1 ={
window.registerBehavior1 ={
beforeRegister: function() {
this._createPropertyObserver('beforeProp', 'beforePropChanged1');
this.beforeRegisterCount++;
Expand Down Expand Up @@ -244,7 +244,7 @@
}
};

Polymer.registerBehavior2 ={
window.registerBehavior2 ={
prop2: true,
beforeRegister: function() {
this.beforeRegisterCount++;
Expand All @@ -254,7 +254,7 @@
}
};

Polymer.registerBehavior3 ={
window.registerBehavior3 ={
prop3: true,
beforeRegister: function() {
this.beforeRegisterCount++;
Expand All @@ -266,9 +266,9 @@

Polymer({
behaviors: [
Polymer.registerBehavior1,
Polymer.registerBehavior2,
Polymer.registerBehavior3
window.registerBehavior1,
window.registerBehavior2,
window.registerBehavior3
],
prop4: true,
beforeRegister: function() {
Expand Down Expand Up @@ -468,18 +468,18 @@
test('behavior array is unique', function() {
Polymer({
is: 'behavior-unique',
behaviors: [Polymer.BehaviorA, Polymer.BehaviorA]
behaviors: [window.BehaviorA, window.BehaviorA]
});
assert.equal(document.createElement('behavior-unique').behaviors.length, 1);
});

test('duplicate behaviors keep first behavior', function() {
Polymer({
is: 'behavior-unique-last-behavior',
behaviors: [Polymer.BehaviorA, Polymer.BehaviorB, Polymer.BehaviorC, Polymer.BehaviorA, Polymer.BehaviorB]
behaviors: [window.BehaviorA, window.BehaviorB, window.BehaviorC, window.BehaviorA, window.BehaviorB]
});
var behaviors = document.createElement('behavior-unique-last-behavior').behaviors;
assert.deepEqual(behaviors, [Polymer.BehaviorC, Polymer.BehaviorA, Polymer.BehaviorB]);
assert.deepEqual(behaviors, [window.BehaviorC, window.BehaviorA, window.BehaviorB]);
});

});
Expand Down
10 changes: 5 additions & 5 deletions test/unit/configure.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</head>
<body>
<script>
var configureBehavior = {
window.configureBehavior = {

changeHandlerCount: 0,
objectChangeHandlerCount: 0,
Expand All @@ -43,7 +43,7 @@

is: 'x-configure-value',

behaviors: [configureBehavior],
behaviors: [window.configureBehavior],

properties: {
content: {
Expand Down Expand Up @@ -82,7 +82,7 @@

is: 'x-configure-gchild',

behaviors: [configureBehavior],
behaviors: [window.configureBehavior],

properties: {
content: {
Expand Down Expand Up @@ -121,7 +121,7 @@

is: 'x-configure-child',

behaviors: [configureBehavior],
behaviors: [window.configureBehavior],

properties: {
content: {
Expand Down Expand Up @@ -222,7 +222,7 @@

is: 'x-configure-host',

behaviors: [configureBehavior],
behaviors: [window.configureBehavior],

properties: {
content: {
Expand Down
20 changes: 11 additions & 9 deletions test/unit/dom-repeat-elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,9 @@
});
</script>

<dom-module id="x-nested-repeat">
<template>
<script>
let XNestedRepeat = Polymer({
_template: `
<template id="repeater" is="dom-repeat" items="{{items}}" as="itema" index-as="indexa" on-dom-change="domUpdateHandler">
<x-foo on-test1="testHandler1"
innera-prop="{{innera.prop}}"
Expand Down Expand Up @@ -241,14 +242,11 @@
indexa="{{indexa}}"
indexb="{{indexb}}"
indexc="{{indexc}}">
</x-foo>
</x-foo>
</template>
</template>
</template>
</template>
</dom-module>
<script>
let XNestedRepeat = Polymer({
`,
is: 'x-nested-repeat',
testHandler1Count: 0,
testHandler2Count: 0,
Expand All @@ -269,7 +267,11 @@
});
class XNestedRepeatMutable extends Polymer.MutableData(XNestedRepeat) {
static get template() {
return this.makeRepeatsMutable(XNestedRepeat.template.cloneNode(true));
if (!this._templateEl) {
this._templateEl = document.createElement('template');
this._templateEl.innerHTML = XNestedRepeat.template;
}
return this.makeRepeatsMutable(this._templateEl.cloneNode(true));
}
static makeRepeatsMutable(template) {
Array.from(template.content.querySelectorAll('[is=dom-repeat]')).forEach(e => {
Expand Down Expand Up @@ -525,4 +527,4 @@
}
});
</script>
</dom-module>
</dom-module>
19 changes: 10 additions & 9 deletions test/unit/dom-repeat.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ <h4>x-repeat-chunked</h4>

<script>
(function() {
/* global limited inDocumentRepeater inDocumentContainer inDocumentContainerOrig stamped:true chunked nonUpgrade*/
'use strict';
/* global limited inDocumentRepeater inDocumentContainer inDocumentContainerOrig chunked nonUpgrade*/

/*
Expected:
Expand Down Expand Up @@ -3607,7 +3608,7 @@ <h4>x-repeat-chunked</h4>
test('increase limit above items.length', function() {
limited.$.repeater.__limit = 30;
limited.$.repeater.render();
stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
var stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped.length, 20);
checkItemOrder(stamped);
});
Expand All @@ -3629,7 +3630,7 @@ <h4>x-repeat-chunked</h4>
test('negative limit', function() {
limited.$.repeater.__limit = -10;
limited.$.repeater.render();
stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
var stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped.length, 0);
});

Expand Down Expand Up @@ -3675,7 +3676,7 @@ <h4>x-repeat-chunked</h4>
test('increase limit above items.length', function() {
limited.$.repeater.__limit = 30;
limited.$.repeater.render();
stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
var stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped.length, 20);
checkItemOrder(stamped);
});
Expand All @@ -3697,7 +3698,7 @@ <h4>x-repeat-chunked</h4>
test('negative limit', function() {
limited.$.repeater.__limit = -10;
limited.$.repeater.render();
stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
var stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped.length, 0);
});

Expand Down Expand Up @@ -3745,7 +3746,7 @@ <h4>x-repeat-chunked</h4>
test('increase limit above items.length', function() {
limited.$.repeater.__limit = 30;
limited.$.repeater.render();
stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
var stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped.length, 10);
checkItemOrder(stamped);
});
Expand All @@ -3767,7 +3768,7 @@ <h4>x-repeat-chunked</h4>
test('negative limit', function() {
limited.$.repeater.__limit = -10;
limited.$.repeater.render();
stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
var stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped.length, 0);
});

Expand Down Expand Up @@ -3817,7 +3818,7 @@ <h4>x-repeat-chunked</h4>
test('increase limit above items.length', function() {
limited.$.repeater.__limit = 30;
limited.$.repeater.render();
stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
var stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped.length, 10);
checkItemOrder(stamped);
});
Expand All @@ -3839,7 +3840,7 @@ <h4>x-repeat-chunked</h4>
test('negative limit', function() {
limited.$.repeater.__limit = -10;
limited.$.repeater.render();
stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
var stamped = limited.root.querySelectorAll('*:not(template):not(dom-repeat)');
assert.equal(stamped.length, 0);
});

Expand Down
Loading

0 comments on commit 3fd628c

Please sign in to comment.