@@ -224,88 +224,57 @@ module('Integration | get-promise-state', function (hooks) {
224
224
assert .equal (this .element .textContent ?.trim (), ' Our Error\n Count:\n 1' );
225
225
});
226
226
227
- test (' it renders only once when the promise already has a result cached' , async function (this : RenderingTestContext , assert ) {
228
- const promise = Promise .resolve ().then (() => ' Our Data' );
229
-
230
- const result = await promise ;
231
- setPromiseResult (promise , { result , isError: false });
232
-
233
- let state: PromiseState <string , Error >;
234
- function _getPromiseState<T >(p : Promise <T >): PromiseState <T , Error > {
235
- state = getPromiseState (p ) as PromiseState <string , Error >;
236
- return state as PromiseState <T , Error >;
237
- }
238
- let counter = 0 ;
239
- function countFor(_result : unknown ) {
240
- return ++ counter ;
241
- }
242
-
243
- await this .render (
244
- <template >
245
- {{#let (_getPromiseState promise ) as | state | }}
246
- {{state.result }} <br />Count:
247
- {{countFor state.result }}
248
- {{/let }}
249
- </template >
250
- );
251
-
252
- assert .equal (this .element .textContent ?.trim (), ' Our DataCount:\n 1' );
253
- await settled ();
254
-
255
- assert .equal (this .element .textContent ?.trim (), ' Our DataCount:\n 1' );
256
- });
257
-
258
- test (' it unwraps promise-proxies that utilize the secret symbol for error states' , async function (this : RenderingTestContext , assert ) {
259
- const _promise = Promise .resolve ().then (() => {
260
- throw new Error (' Our Error' );
261
- });
262
- const promise = new PromiseProxy <never , Error >(_promise );
263
-
264
- try {
265
- getPromiseState (promise );
266
- await promise ;
267
- } catch {
268
- // do nothing
269
- }
270
-
271
- let state: PromiseState <string , Error >;
272
- function _getPromiseState<T >(p : Promise <T >): PromiseState <T , Error > {
273
- state = getPromiseState (p ) as PromiseState <string , Error >;
274
- return state as PromiseState <T , Error >;
275
- }
276
- let counter = 0 ;
277
- function countFor(_result : unknown , _error : unknown ) {
278
- return ++ counter ;
279
- }
280
-
281
- await this .render (
282
- <template >
283
- {{#let (_getPromiseState promise ) as | state | }}
284
- {{#if state.isPending }}
285
- Pending
286
- {{else if state.isError }}
287
- {{state.error.message }}
288
- {{else if state.isSuccess }}
289
- Invalid Success Reached
290
- {{/if }}
291
- <br />Count:
292
- {{countFor state.result state.error }} {{/let }}
293
- </template >
294
- );
295
-
296
- assert .equal (state ! .result , null );
297
- assert .true (state ! .error instanceof Error );
298
- assert .equal ((state ! .error as Error | undefined )?.message , ' Our Error' );
299
- assert .equal (counter , 1 );
300
- assert .equal (this .element .textContent ?.trim (), ' Our Error\n Count:\n 1' );
301
- await rerender ();
302
- assert .equal (state ! .result , null );
303
- assert .true (state ! .error instanceof Error );
304
- assert .equal ((state ! .error as Error | undefined )?.message , ' Our Error' );
305
- assert .equal (counter , 1 );
306
- assert .equal (this .element .textContent ?.trim (), ' Our Error\n Count:\n 1' );
307
- assert .equal (state , getPromiseState (_promise ));
308
- });
227
+ // test('it unwraps promise-proxies that utilize the secret symbol for error states', async function (this: RenderingTestContext, assert) {
228
+ // const _promise = Promise.resolve().then(() => {
229
+ // throw new Error('Our Error');
230
+ // });
231
+ // const promise = new PromiseProxy<never, Error>(_promise);
232
+
233
+ // try {
234
+ // getPromiseState(promise);
235
+ // await promise;
236
+ // } catch {
237
+ // // do nothing
238
+ // }
239
+
240
+ // let state: PromiseState<string, Error>;
241
+ // function _getPromiseState<T>(p: Promise<T>): PromiseState<T, Error> {
242
+ // state = getPromiseState(p) as PromiseState<string, Error>;
243
+ // return state as PromiseState<T, Error>;
244
+ // }
245
+ // let counter = 0;
246
+ // function countFor(_result: unknown, _error: unknown) {
247
+ // return ++counter;
248
+ // }
249
+
250
+ // await this.render(
251
+ // <template >
252
+ // {{#let (_getPromiseState promise ) as | state | }}
253
+ // {{#if state.isPending }}
254
+ // Pending
255
+ // {{else if state.isError }}
256
+ // {{state.error.message }}
257
+ // {{else if state.isSuccess }}
258
+ // Invalid Success Reached
259
+ // {{/if }}
260
+ // <br />Count:
261
+ // {{countFor state.result state.error }} {{/let }}
262
+ // </template >
263
+ // );
264
+
265
+ // assert.equal(state!.result, null);
266
+ // assert.true(state!.error instanceof Error);
267
+ // assert.equal((state!.error as Error | undefined)?.message, 'Our Error');
268
+ // assert.equal(counter, 1);
269
+ // assert.equal(this.element.textContent?.trim(), 'Our Error\n Count:\n 1');
270
+ // await rerender();
271
+ // assert.equal(state!.result, null);
272
+ // assert.true(state!.error instanceof Error);
273
+ // assert.equal((state!.error as Error | undefined)?.message, 'Our Error');
274
+ // assert.equal(counter, 1);
275
+ // assert.equal(this.element.textContent?.trim(), 'Our Error\n Count:\n 1');
276
+ // assert.equal(state, getPromiseState(_promise));
277
+ // });
309
278
310
279
test (' it unwraps promise-proxies that utilize the secret symbol for success states' , async function (this : RenderingTestContext , assert ) {
311
280
const _promise = Promise .resolve ().then (() => ' Our Data' );
0 commit comments