Skip to content
This repository was archived by the owner on Sep 7, 2022. It is now read-only.

Commit 642f1b5

Browse files
committed
test(Fix tests in older browsers by only including the custom element polyfill and triggering built-
1 parent dd54493 commit 642f1b5

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

karma.conf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = function (config) {
44

55
// WebComponentsJS for testing native APIs in older browsers.
66
config.files = [
7-
'node_modules/webcomponents.js/webcomponents.js',
7+
'node_modules/webcomponents.js/CustomElements.js',
88
].concat(config.files);
99

1010
// Ensure mobile browsers have enough time to run.

test/unit/custom-events.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@ import React from 'react';
33
import ReactDOM from 'react-dom';
44

55
describe('custom events', () => {
6-
it('should bind built-in events', () => {
6+
it('should bind built-in events', done => {
77
let count = 0;
88
const Comp = reactify(document.registerElement('x-custom-event-1', {
99
prototype: Object.create(HTMLElement.prototype, {
1010
trigger: {
1111
value() {
12-
this.dispatchEvent(new MouseEvent('click'));
12+
this.dispatchEvent(new CustomEvent('click'));
1313
},
1414
},
1515
}),
1616
}), { React, ReactDOM });
17-
const comp = ReactDOM.render(<Comp onclick={() => count++} />, window.fixture);
17+
const comp = ReactDOM.render(<Comp onClick={() => count++} />, window.fixture);
1818

1919
setTimeout(() => {
2020
ReactDOM.findDOMNode(comp).trigger();
2121
expect(count).to.equal(1);
22+
done();
2223
}, 1);
2324
});
2425

25-
it('should bind custom events', () => {
26+
it('should bind custom events', done => {
2627
let count = 0;
2728
const Comp = reactify(document.registerElement('x-custom-event-2', {
2829
prototype: Object.create(HTMLElement.prototype, {
@@ -38,6 +39,7 @@ describe('custom events', () => {
3839
setTimeout(() => {
3940
ReactDOM.findDOMNode(comp).trigger();
4041
expect(count).to.equal(1);
42+
done();
4143
}, 1);
4244
});
4345
});

0 commit comments

Comments
 (0)