@@ -1645,7 +1645,7 @@ describe('field directive', () => {
16451645
16461646 describe ( 'pending' , ( ) => {
16471647 it ( 'should bind to custom control' , async ( ) => {
1648- const { promise, resolve} = promiseWithResolvers < ValidationError [ ] > ( ) ;
1648+ const { promise, resolve} = Promise . withResolvers < ValidationError [ ] > ( ) ;
16491649
16501650 @Component ( {
16511651 selector : 'custom-control' ,
@@ -1690,7 +1690,7 @@ describe('field directive', () => {
16901690 } ) ;
16911691
16921692 it ( 'should bind to a custom control when composed as a host directive' , async ( ) => {
1693- const { promise, resolve} = promiseWithResolvers < ValidationError [ ] > ( ) ;
1693+ const { promise, resolve} = Promise . withResolvers < ValidationError [ ] > ( ) ;
16941694
16951695 @Component ( {
16961696 selector : 'custom-control' ,
@@ -1736,7 +1736,7 @@ describe('field directive', () => {
17361736 } ) ;
17371737
17381738 it ( 'should be reset when field changes on custom control' , async ( ) => {
1739- const { promise, resolve} = promiseWithResolvers < ValidationError [ ] > ( ) ;
1739+ const { promise, resolve} = Promise . withResolvers < ValidationError [ ] > ( ) ;
17401740
17411741 @Component ( { selector : 'custom-control' , template : `` } )
17421742 class CustomControl implements FormValueControl < string > {
@@ -1780,7 +1780,7 @@ describe('field directive', () => {
17801780 } ) ;
17811781
17821782 it ( 'should bind to directive input on native control' , async ( ) => {
1783- const { promise, resolve} = promiseWithResolvers < ValidationError [ ] > ( ) ;
1783+ const { promise, resolve} = Promise . withResolvers < ValidationError [ ] > ( ) ;
17841784
17851785 @Directive ( { selector : '[testDir]' } )
17861786 class TestDir {
@@ -1818,7 +1818,7 @@ describe('field directive', () => {
18181818 } ) ;
18191819
18201820 it ( 'should bind to directive input on custom control' , async ( ) => {
1821- const { promise, resolve} = promiseWithResolvers < ValidationError [ ] > ( ) ;
1821+ const { promise, resolve} = Promise . withResolvers < ValidationError [ ] > ( ) ;
18221822
18231823 @Directive ( { selector : '[testDir]' } )
18241824 class TestDir {
@@ -5032,7 +5032,7 @@ describe('field directive', () => {
50325032 } ) ;
50335033
50345034 it ( 'should synchronize pending status' , async ( ) => {
5035- const { promise, resolve} = promiseWithResolvers < ValidationError [ ] > ( ) ;
5035+ const { promise, resolve} = Promise . withResolvers < ValidationError [ ] > ( ) ;
50365036
50375037 @Component ( {
50385038 selector : 'my-input' ,
@@ -5927,7 +5927,7 @@ describe('field directive', () => {
59275927
59285928 describe ( 'debounce' , ( ) => {
59295929 it ( 'should support native control' , async ( ) => {
5930- const { promise, resolve} = promiseWithResolvers < void > ( ) ;
5930+ const { promise, resolve} = Promise . withResolvers < void > ( ) ;
59315931
59325932 @Component ( {
59335933 imports : [ FormField ] ,
@@ -5954,7 +5954,7 @@ describe('field directive', () => {
59545954 } ) ;
59555955
59565956 it ( 'should support custom control' , async ( ) => {
5957- const { promise, resolve} = promiseWithResolvers < void > ( ) ;
5957+ const { promise, resolve} = Promise . withResolvers < void > ( ) ;
59585958
59595959 @Component ( {
59605960 selector : 'my-input' ,
@@ -5986,7 +5986,7 @@ describe('field directive', () => {
59865986 } ) ;
59875987
59885988 it ( 'should reset control when debounced update is reset' , async ( ) => {
5989- const { promise, resolve} = promiseWithResolvers < void > ( ) ;
5989+ const { promise, resolve} = Promise . withResolvers < void > ( ) ;
59905990
59915991 @Component ( {
59925992 imports : [ FormField ] ,
@@ -6024,7 +6024,7 @@ describe('field directive', () => {
60246024 } ) ;
60256025
60266026 it ( 'should reset child control when debounced update is reset at root' , async ( ) => {
6027- const { promise, resolve} = promiseWithResolvers < void > ( ) ;
6027+ const { promise, resolve} = Promise . withResolvers < void > ( ) ;
60286028
60296029 @Component ( {
60306030 imports : [ FormField ] ,
@@ -6218,7 +6218,7 @@ describe('field directive', () => {
62186218 } ) ;
62196219
62206220 it ( 'should create & bind input when a macro task is running' , async ( ) => {
6221- const { promise, resolve} = promiseWithResolvers < void > ( ) ;
6221+ const { promise, resolve} = Promise . withResolvers < void > ( ) ;
62226222
62236223 @Component ( {
62246224 selector : 'app-form' ,
@@ -6490,25 +6490,3 @@ function act<T>(fn: () => T): T {
64906490 TestBed . tick ( ) ;
64916491 }
64926492}
6493-
6494- /**
6495- * Replace with `Promise.withResolvers()` once it's available.
6496- *
6497- * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/withResolvers.
6498- */
6499- // TODO: share this with submit.spec.ts
6500- function promiseWithResolvers < T = void > ( ) : {
6501- promise : Promise < T > ;
6502- resolve : ( value : T | PromiseLike < T > ) => void ;
6503- reject : ( reason ?: any ) => void ;
6504- } {
6505- let resolve ! : ( value : T | PromiseLike < T > ) => void ;
6506- let reject ! : ( reason ?: any ) => void ;
6507-
6508- const promise = new Promise < T > ( ( res , rej ) => {
6509- resolve = res ;
6510- reject = rej ;
6511- } ) ;
6512-
6513- return { promise, resolve, reject} ;
6514- }
0 commit comments