mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-31 18:59:23 +00:00 
			
		
		
		
	
		
			
	
	
		
			26 lines
		
	
	
		
			735 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
		
		
			
		
	
	
			26 lines
		
	
	
		
			735 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
|   | import Sinon from 'sinon'; | ||
|  | 
 | ||
|  | /** | ||
|  |  * Local convenience interface for return value from setupSinonTest | ||
|  |  * @interface ISinonRequested | ||
|  |  */ | ||
|  | interface ISinonRequested { | ||
|  |   request?: Sinon.SinonFakeXMLHttpRequest; | ||
|  |   requester: Sinon.SinonFakeXMLHttpRequestStatic; | ||
|  | } | ||
|  | 
 | ||
|  | /** | ||
|  |  * Convenience function to setup environment for sinon test | ||
|  |  * | ||
|  |  * @param {SinonTestContext} context a reference to the sinon test case's this | ||
|  |  * @returns {ISinonRequested} | ||
|  |  */ | ||
|  | export const setupSinonTest = (context: SinonTestContext): ISinonRequested => { | ||
|  |   const setupValue: ISinonRequested = { request: undefined, requester: context.sandbox.useFakeXMLHttpRequest() }; | ||
|  |   setupValue.requester.onCreate = req => { | ||
|  |     setupValue.request = req; | ||
|  |   }; | ||
|  | 
 | ||
|  |   return setupValue; | ||
|  | }; |