-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.js
More file actions
49 lines (42 loc) · 1.42 KB
/
Copy pathtest.js
File metadata and controls
49 lines (42 loc) · 1.42 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict'
var promises = require('./index')
var assert = require('assert')
console.log('test getPromiseConstructor')
void function () {
var Promise = promises.getPromiseConstructor('q') // q implementation
var p = new Promise(function (resolve) { resolve(1) })
p.then(function (x) { assert(x === 1) })
}()
console.log('test default')
void function () {
var P = promises.default
if (P) {
var p = new P(function (resolve) { resolve(1) })
p.then(function (x) { assert(x === 1) })
}
}()
console.log('test list')
var list = promises.list
list.forEach(function (impl, index) {
console.log(index + '.',
'package name:', impl.name,
'aliases:', impl.aliases,
'version:', impl.version)
var Promise = impl.Promise // Promise constructor
if (Promise) Promise.resolve(1).then(function (x) { assert(x === 1) })
else console.warn(impl.error)
})
console.log('test has/get/register/unregister')
promises.has('es6-promise-polyfill') // false
promises.register('es6-promise-polyfill', [], 'Polyfill')
promises.has('es6-promise-polyfill') // true
var impl = promises.get('es6-promise-polyfill')
assert.deepEqual(impl, {
name: 'es6-promise-polyfill',
version: require('es6-promise-polyfill/package.json').version,
aliases: [],
Promise: promises.getPromiseConstructor('es6-promise-polyfill'),
})
promises.unregister('es6-promise-polyfill') // true
promises.has('es6-promise-polyfill') // false
promises.unregister('es6-promise-polyfill') // false