Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Commit

Permalink
Adding intersection observer polyfill and functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rorticus committed Oct 10, 2017
1 parent adf3bbe commit 0dcd688
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"typescript": "~2.4.1"
},
"dependencies": {
"intersection-observer": "^0.4.2",
"pepjs": "^0.4.2",
"tslib": "^1.7.1"
}
Expand Down
1 change: 1 addition & 0 deletions tests/functional/all.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import './asyncAwait';
import './polyfills';
26 changes: 26 additions & 0 deletions tests/functional/polyfills.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>Basic AMD Loading Test</title>
</head>

<body>
<script src="../../src/util/amd.js"></script>
<script src="../../../node_modules/@dojo/loader/loader.js"></script>
<script>
require.config(shimAmdDependencies({
baseUrl: '../../../'
}));
require([
'_build/src/main',
'_build/src/browser'
], function() {
window.results = {
pointerEvents: typeof(PointerEvent) !== 'undefined',
intersectionObserver: typeof(IntersectionObserver) !== 'undefined'
};
});
</script>
</body>
</html>
22 changes: 22 additions & 0 deletions tests/functional/polyfills.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { registerSuite } = intern.getInterface('object');
const { assert } = intern.getPlugin('chai');
import pollUntil from '@theintern/leadfoot/helpers/pollUntil';

interface CallbackResults {
intersectionObserver: boolean;
pointerEvents: boolean;
}

registerSuite('Polyfills', {
'Polyfills'() {
return this.remote
.get('/_build/tests/functional/polyfills.html')
.then(pollUntil(function () {
return (<any> window).results;
}, undefined, 5000), undefined)
.then((results: CallbackResults) => {
assert.isTrue(results.pointerEvents, 'Expected pointer events to be available');
assert.isTrue(results.intersectionObserver, 'Expected intersection observer to be available');
});
}
});

0 comments on commit 0dcd688

Please sign in to comment.