@@ -6,15 +6,6 @@ QUnit.test('Promise.allKeyed', assert => {
6
6
assert . true ( Promise . allKeyed ( { } ) instanceof Promise , 'returns a promise' ) ;
7
7
} ) ;
8
8
9
- QUnit . test ( 'Promise.allKeyed, rejected on incorrect input' , assert => {
10
- return Promise . allKeyed ( 'string' ) . then ( ( ) => {
11
- assert . avoid ( ) ;
12
- } , error => {
13
- assert . true ( error instanceof TypeError , 'error is TypeError' ) ;
14
- assert . required ( 'rejected as expected' ) ;
15
- } ) ;
16
- } ) ;
17
-
18
9
QUnit . test ( 'Promise.allKeyed, resolved' , assert => {
19
10
return Promise . allKeyed ( {
20
11
a : Promise . resolve ( 1 ) ,
@@ -56,6 +47,15 @@ QUnit.test('Promise.allKeyed, resolved with hidden attributes', assert => {
56
47
} ) ;
57
48
} ) ;
58
49
50
+ QUnit . test ( 'Promise.allKeyed, rejected on incorrect input' , assert => {
51
+ return Promise . allKeyed ( 'string' ) . then ( ( ) => {
52
+ assert . avoid ( ) ;
53
+ } , error => {
54
+ assert . true ( error instanceof TypeError , 'error is TypeError' ) ;
55
+ assert . required ( 'rejected as expected' ) ;
56
+ } ) ;
57
+ } ) ;
58
+
59
59
QUnit . test ( 'Promise.allKeyed, resolved with timeouts' , assert => {
60
60
return Promise . allKeyed ( {
61
61
a : Promise . resolve ( 1 ) ,
@@ -70,6 +70,34 @@ QUnit.test('Promise.allKeyed, resolved with timeouts', assert => {
70
70
} ) ;
71
71
} ) ;
72
72
73
+ QUnit . test ( 'Promise.allKeyed, subclassing' , assert => {
74
+ const { allKeyed, resolve } = Promise ;
75
+ const FakePromise1 = function ( executor ) {
76
+ executor ( ( ) => { /* empty */ } , ( ) => { /* empty */ } ) ;
77
+ } ;
78
+ FakePromise1 . resolve = resolve . bind ( Promise ) ;
79
+ assert . true ( allKeyed . call ( FakePromise1 , { a : Promise . resolve ( 1 ) } ) instanceof FakePromise1 , 'subclassing, `this` pattern' ) ;
80
+ } ) ;
81
+
82
+ QUnit . test ( 'Promise.allKeyed, without constructor context' , assert => {
83
+ const { allKeyed } = Promise ;
84
+ assert . throws ( ( ) => allKeyed ( { a : 1 } ) , TypeError , 'Throws if called without a constructor context' ) ;
85
+ assert . throws ( ( ) => allKeyed . call ( null , { a : 1 } ) , TypeError , 'Throws if called with null as this' ) ;
86
+ } ) ;
87
+
88
+ QUnit . test ( 'Promise.allKeyed, result object has null prototype' , assert => {
89
+ return Promise . allKeyed ( {
90
+ a : Promise . resolve ( 1 ) ,
91
+ b : Promise . resolve ( 2 ) ,
92
+ } ) . then ( result => {
93
+ assert . strictEqual (
94
+ Object . getPrototypeOf ( result ) ,
95
+ null ,
96
+ 'Result object has null prototype' ,
97
+ ) ;
98
+ } ) ;
99
+ } ) ;
100
+
73
101
QUnit . test ( 'Promise.allKeyed, symbol keys' , assert => {
74
102
const symA = Symbol ( 'A' ) ;
75
103
const symB = Symbol ( 'B' ) ;
@@ -94,34 +122,3 @@ QUnit.test('Promise.allKeyed, keys order', assert => {
94
122
assert . deepEqual ( actualKeys , [ 'a' , 'b' , 'c' ] , 'correct order in the case when promises resolves in different order' ) ;
95
123
} ) ;
96
124
} ) ;
97
-
98
- QUnit . test ( 'Promise.allKeyed, without constructor context' , assert => {
99
- const { allKeyed } = Promise ;
100
- assert . throws ( ( ) => allKeyed ( { a : 1 } ) , TypeError , 'Throws if called without a constructor context' ) ;
101
- assert . throws ( ( ) => allKeyed . call ( null , { a : 1 } ) , TypeError , 'Throws if called with null as this' ) ;
102
- } ) ;
103
-
104
- QUnit . test ( 'Promise.allKeyed, fake promises' , assert => {
105
- const { allKeyed } = Promise ;
106
- const FakePromise1 = function ( executor ) {
107
- executor ( ( ) => { /* empty */ } , ( ) => { /* empty */ } ) ;
108
- } ;
109
- const FakePromise2 = FakePromise1 [ Symbol . species ] = function ( executor ) {
110
- executor ( ( ) => { /* empty */ } , ( ) => { /* empty */ } ) ;
111
- } ;
112
- FakePromise1 . resolve = FakePromise2 . resolve = Promise . resolve . bind ( Promise ) ;
113
- assert . true ( allKeyed . call ( FakePromise1 , { a : Promise . resolve ( 1 ) } ) instanceof FakePromise1 , 'subclassing, `this` pattern' ) ;
114
- } ) ;
115
-
116
- QUnit . test ( 'Promise.allKeyed, result object has null prototype' , assert => {
117
- return Promise . allKeyed ( {
118
- a : Promise . resolve ( 1 ) ,
119
- b : Promise . resolve ( 2 ) ,
120
- } ) . then ( result => {
121
- assert . strictEqual (
122
- Object . getPrototypeOf ( result ) ,
123
- null ,
124
- 'Result object has null prototype' ,
125
- ) ;
126
- } ) ;
127
- } ) ;
0 commit comments