mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-10-31 19:17:48 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			28 lines
		
	
	
		
			809 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			28 lines
		
	
	
		
			809 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| function apiSpecHelper() {
 | |
|   beforeEach(() => {
 | |
|     this.originalAxios = window.axios;
 | |
|     this.axiosMock = {
 | |
|       post: jest.fn(() => Promise.resolve()),
 | |
|       get: jest.fn(() => Promise.resolve()),
 | |
|       patch: jest.fn(() => Promise.resolve()),
 | |
|       delete: jest.fn(() => Promise.resolve()),
 | |
|     };
 | |
|     window.axios = this.axiosMock;
 | |
|   });
 | |
| 
 | |
|   afterEach(() => {
 | |
|     window.axios = this.originalAxios;
 | |
|   });
 | |
| }
 | |
| // https://stackoverflow.com/a/59344023/3901856
 | |
| const sharedWrapper = describe('sharedWrapper', () => {});
 | |
| export default function describeWithAPIMock(skillName, testFn) {
 | |
|   return describe(skillName, function configureContext() {
 | |
|     function Context() {}
 | |
|     Context.prototype = sharedWrapper.ctx;
 | |
|     this.ctx = new Context();
 | |
|     apiSpecHelper.call(this);
 | |
|     testFn.call(this, this);
 | |
|   });
 | |
| }
 | 
