Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Garcia committed Nov 2, 2016
1 parent 132010e commit 29de005
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/unit/dynamic-import.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,40 @@
}, null, true);
});

test('importHref does not leak event listeners on load', function(done) {
var errorSpy = sinon.spy();
var loadSpy = sinon.spy(function(e) {
var target = e.target;
target.dispatchEvent(new Event('error'));
assert.isFalse(errorSpy.called, 'doesn\'t trigger the error event listener');
setTimeout(function() {
loadSpy.reset();
target.dispatchEvent(new Event('load'));
assert.isFalse(loadSpy.called, 'doesn\'t trigger the load event listener');
done();
});
});

Polymer.Base.importHref('dynamic-imports/async-import.html', loadSpy, errorSpy, true);
});

test('importHref does not leak event listeners on error', function(done) {
var loadSpy = sinon.spy();
var errorSpy = sinon.spy(function(e) {
var target = e.target;
target.dispatchEvent(new Event('load'));
assert.isFalse(loadSpy.called, 'doesn\'t trigger the load event listener');
setTimeout(function() {
errorSpy.reset();
target.dispatchEvent(new Event('error'));
assert.isFalse(errorSpy.called, 'doesn\'t trigger the error event listener');
done();
});
});

Polymer.Base.importHref('dynamic-imports/async-import-invalid.html', loadSpy, errorSpy, true);
});

});

});
Expand Down

0 comments on commit 29de005

Please sign in to comment.