File tree Expand file tree Collapse file tree 1 file changed +32
-30
lines changed
Expand file tree Collapse file tree 1 file changed +32
-30
lines changed Original file line number Diff line number Diff line change @@ -105,39 +105,41 @@ describe('delays runtime behavior', () => {
105105 expect ( consoleWarnSpy ) . not . toHaveBeenCalled ( ) ;
106106 } ) ;
107107
108- it ( 'should transition immediately when unknown delay is used (current behavior)' , ( done : any ) => {
109- const machine = setup ( {
110- delays : {
111- knownDelay : 100
112- }
113- } ) . createMachine ( {
114- initial : 'a' ,
115- states : {
116- a : {
117- after : {
118- unknownDelay : 'b' as any // TypeScript can't catch this due to TS#55709
108+ it ( 'should transition immediately when unknown delay is used (current behavior)' , ( ) => {
109+ return new Promise < void > ( ( resolve , reject ) => {
110+ const machine = setup ( {
111+ delays : {
112+ knownDelay : 100
113+ }
114+ } ) . createMachine ( {
115+ initial : 'a' ,
116+ states : {
117+ a : {
118+ after : {
119+ unknownDelay : 'b' as any // TypeScript can't catch this due to TS#55709
120+ }
121+ } ,
122+ b : {
123+ type : 'final'
119124 }
120- } ,
121- b : {
122- type : 'final'
123125 }
124- }
125- } ) ;
126-
127- const actor = createActor ( machine ) ;
128-
129- actor . subscribe ( {
130- complete : ( ) => {
131- // Should complete immediately since unknownDelay is undefined
132- done ( ) ;
133- }
134- } ) ;
126+ } ) ;
127+
128+ const actor = createActor ( machine ) ;
129+
130+ actor . subscribe ( {
131+ complete : ( ) => {
132+ // Should complete immediately since unknownDelay is undefined
133+ resolve ( ) ;
134+ }
135+ } ) ;
135136
136- actor . start ( ) ;
137+ actor . start ( ) ;
137138
138- // If the test doesn't complete quickly, it means the transition didn't happen immediately
139- setTimeout ( ( ) => {
140- done ( new Error ( 'Should have transitioned immediately' ) ) ;
141- } , 50 ) ;
139+ // If the test doesn't complete quickly, it means the transition didn't happen immediately
140+ setTimeout ( ( ) => {
141+ reject ( new Error ( 'Should have transitioned immediately' ) ) ;
142+ } , 50 ) ;
143+ } ) ;
142144 } ) ;
143145} ) ;
You can’t perform that action at this time.
0 commit comments