Skip to content

Commit

Permalink
Merge pull request #15 from PolymerElements/fixMSEdge
Browse files Browse the repository at this point in the history
Synchronous tests; rewrote detach basic test
  • Loading branch information
e111077 committed Feb 12, 2016
2 parents bb9b759 + dbdb77c commit f0d5511
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 79 deletions.
118 changes: 39 additions & 79 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

suite('x-resizer-parent', function() {

test('notify resizables from window', function(done) {
test('notify resizables from window', function() {
var listeners = [
ListenForResize(testEl.$.parent),
ListenForResize(testEl.$.child1a),
Expand All @@ -91,22 +91,13 @@
ListenForResize(testEl.$.shadow1d.$.resizable)
];

setTimeout(function() {
try {
window.dispatchEvent(new CustomEvent('resize', { bubbles: false }));

expect(pendingNotifications).to.be.eql(0);
window.dispatchEvent(new CustomEvent('resize', { bubbles: false }));
expect(pendingNotifications).to.be.eql(0);

RemoveListeners(listeners);

done();
} catch (e) {
done(e);
}
}, 0);
RemoveListeners(listeners);
});

test('notify resizables from parent', function(done) {
test('notify resizables from parent', function() {
var listeners = [
ListenForResize(testEl.$.parent),
ListenForResize(testEl.$.child1a),
Expand All @@ -115,43 +106,33 @@
ListenForResize(testEl.$.shadow1d.$.resizable)
];

setTimeout(function() {
try {
testEl.$.parent.notifyResize();
expect(pendingNotifications).to.be.eql(0);
RemoveListeners(listeners);
done();
} catch (e) {
done(e);
}
}, 0);
testEl.$.parent.notifyResize();
expect(pendingNotifications).to.be.eql(0);
RemoveListeners(listeners);
});

test('detach resizables then notify parent', function(done) {
var listeners = [
ListenForResize(testEl.$.parent),
ListenForResize(testEl.$.child1a, false),
ListenForResize(testEl.$.child1b),
ListenForResize(testEl.$.shadow1c.$.resizable, false),
ListenForResize(testEl.$.shadow1d.$.resizable)
];
test('detach resizables then notify parent', function() {
sinon.spy(testEl.$.child1a, 'notifyResize');
sinon.spy(testEl.$.shadow1c.$.resizable, 'notifyResize');
sinon.spy(testEl.$.child1b, 'notifyResize');
sinon.spy(testEl.$.shadow1d.$.resizable, 'notifyResize');

var el = Polymer.dom(testEl.root).querySelector('#child1a');
var firstElementToRemove = testEl.$.child1a;
var firstElementParent = Polymer.dom(firstElementToRemove).parentNode;
var secondElementToRemove = testEl.$.shadow1c.$.resizable;
var secondElementParent = Polymer.dom(secondElementToRemove).parentNode;

el.parentNode.removeChild(el);
el = Polymer.dom(testEl.root).querySelector('#shadow1c');
el.parentNode.removeChild(el);
Polymer.dom(firstElementParent).removeChild(firstElementToRemove);
Polymer.dom(secondElementParent).removeChild(secondElementToRemove);

setTimeout(function() {
try {
testEl.$.parent.notifyResize();
expect(pendingNotifications).to.be.eql(0);
RemoveListeners(listeners);
done();
} catch (e) {
done(e);
}
}, 0);
Polymer.dom.flush();

testEl.$.parent.notifyResize();

expect(testEl.$.child1a.notifyResize.callCount).to.be.equal(0);
expect(testEl.$.shadow1c.$.resizable.notifyResize.callCount).to.be.equal(0);
expect(testEl.$.child1b.notifyResize.callCount).to.be.equal(1);
expect(testEl.$.shadow1d.$.resizable.notifyResize.callCount).to.be.equal(1);
});

test('detach parent then notify window', function(done) {
Expand Down Expand Up @@ -183,7 +164,7 @@

suite('x-resizer-parent-filtered', function() {

test('notify resizables from window', function(done) {
test('notify resizables from window', function() {
var listeners = [
ListenForResize(testEl.$.parentFiltered),
ListenForResize(testEl.$.child2a),
Expand All @@ -194,19 +175,12 @@

testEl.$.parentFiltered.active = testEl.$.child2a;

setTimeout(function() {
try {
window.dispatchEvent(new CustomEvent('resize', { bubbles: false }));
expect(pendingNotifications).to.be.eql(0);
RemoveListeners(listeners);
done();
} catch (e) {
done(e);
}
}, 0);
window.dispatchEvent(new CustomEvent('resize', { bubbles: false }));
expect(pendingNotifications).to.be.eql(0);
RemoveListeners(listeners);
});

test('notify resizables from parent', function(done) {
test('notify resizables from parent', function() {
var listeners = [
ListenForResize(testEl.$.parentFiltered),
ListenForResize(testEl.$.child2a),
Expand All @@ -217,19 +191,12 @@

testEl.$.parentFiltered.active = testEl.$.child2a;

setTimeout(function() {
try {
testEl.$.parentFiltered.notifyResize();
expect(pendingNotifications).to.be.eql(0);
RemoveListeners(listeners);
done();
} catch (e) {
done(e);
}
}, 0);
testEl.$.parentFiltered.notifyResize();
expect(pendingNotifications).to.be.eql(0);
RemoveListeners(listeners);
});

test('detach resizables then notify parent', function(done) {
test('detach resizables then notify parent', function() {
var listeners = [
ListenForResize(testEl.$.parentFiltered),
ListenForResize(testEl.$.child2a, false),
Expand All @@ -245,16 +212,9 @@

testEl.$.parentFiltered.active = testEl.$.shadow2d.$.resizable;

setTimeout(function() {
try {
testEl.$.parentFiltered.notifyResize();
expect(pendingNotifications).to.be.eql(0);
RemoveListeners(listeners);
done();
} catch (e) {
done(e);
}
}, 0);
testEl.$.parentFiltered.notifyResize();
expect(pendingNotifications).to.be.eql(0);
RemoveListeners(listeners);
});
});
});
Expand Down
1 change: 1 addition & 0 deletions test/iron-resizable-behavior.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
suite('window\'s resize', function() {
test('causes all iron-resize events to fire once', function() {
window.dispatchEvent(new CustomEvent('resize'));
Polymer.dom.flush();
expect(resizable.ironResizeCount).to.be.equal(2);
expect(resizable.$.childResizable1.ironResizeCount).to.be.equal(2);
expect(resizable.$.childResizable2.ironResizeCount).to.be.equal(2);
Expand Down

0 comments on commit f0d5511

Please sign in to comment.