forked from shaka-project/shaka-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_promise_polyfill.js
executable file
·33 lines (30 loc) · 1.1 KB
/
test_promise_polyfill.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env node
// Tests Shaka's Promises polyfill using the A+ conformance tests.
// Requires node.js, the 'promises-aplus-tests' module, and the compiled Shaka
// Player library.
// Load the compiled library.
var shaka = require('./shaka-player.compiled');
shaka.polyfill.Promise.install();
// Build an adapter for the test suite.
var adapter = {
resolved: Promise.resolve,
rejected: Promise.reject,
deferred: function() {
var resolveFn, rejectFn;
var p = new Promise(function(resolve, reject) {
resolveFn = resolve;
rejectFn = reject;
});
return { promise: p, resolve: resolveFn, reject: rejectFn };
}
};
// Load the test suite and run conformance tests.
// This implementation does not support thenables, which are not used by Shaka
// Player. Tests related to thenables (2.3.3.*) are therefore ignored.
var opts = { 'grep': /^2.3.3/, 'invert': true };
var promisesAplusTests = require('promises-aplus-tests');
promisesAplusTests(adapter, opts, function(err) {
var failures = err ? err.failures : 0;
console.log('FAILURES:', failures);
process.exit(failures ? 1 : 0);
});