test(reactivity): add test case for effectScope (#4239)
This commit is contained in:
		
							parent
							
								
									c46af8fe26
								
							
						
					
					
						commit
						e04680b0aa
					
				| @ -192,6 +192,25 @@ describe('reactivity/effect/scope', () => { | |||||||
|     expect(dummy).toBe(7) |     expect(dummy).toBe(7) | ||||||
|   }) |   }) | ||||||
| 
 | 
 | ||||||
|  |   it('should warn onDispose() is called when there is no active effect scope', () => { | ||||||
|  |     const spy = jest.fn() | ||||||
|  |     const scope = new EffectScope() | ||||||
|  |     scope.run(() => { | ||||||
|  |       onScopeDispose(spy) | ||||||
|  |     }) | ||||||
|  | 
 | ||||||
|  |     expect(spy).toHaveBeenCalledTimes(0) | ||||||
|  | 
 | ||||||
|  |     onScopeDispose(spy) | ||||||
|  | 
 | ||||||
|  |     expect( | ||||||
|  |       '[Vue warn] onDispose() is called when there is no active effect scope to be associated with.' | ||||||
|  |     ).toHaveBeenWarned() | ||||||
|  | 
 | ||||||
|  |     scope.stop() | ||||||
|  |     expect(spy).toHaveBeenCalledTimes(1) | ||||||
|  |   }) | ||||||
|  | 
 | ||||||
|   it('should derefence child scope from parent scope after stopping child scope (no memleaks)', async () => { |   it('should derefence child scope from parent scope after stopping child scope (no memleaks)', async () => { | ||||||
|     const parent = new EffectScope() |     const parent = new EffectScope() | ||||||
|     const child = parent.run(() => new EffectScope())! |     const child = parent.run(() => new EffectScope())! | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user