MOBILE-4420 behat: Support sync network requests
This commit is contained in:
		
							parent
							
								
									1f05729cb0
								
							
						
					
					
						commit
						a4ea36399f
					
				@ -236,15 +236,27 @@ export class TestingBehatBlockingService {
 | 
				
			|||||||
            NgZone.run(() => {
 | 
					            NgZone.run(() => {
 | 
				
			||||||
                const index = requestIndex++;
 | 
					                const index = requestIndex++;
 | 
				
			||||||
                const key = 'httprequest-' + index;
 | 
					                const key = 'httprequest-' + index;
 | 
				
			||||||
 | 
					                const isAsync = args[2] !== false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                try {
 | 
					                try {
 | 
				
			||||||
                    // Add to the list of pending requests.
 | 
					                    // Add to the list of pending requests.
 | 
				
			||||||
                    TestingBehatBlocking.block(key);
 | 
					                    TestingBehatBlocking.block(key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    // Detect when it finishes and remove it from the list.
 | 
					                    // Detect when it finishes and remove it from the list.
 | 
				
			||||||
 | 
					                    if (isAsync) {
 | 
				
			||||||
                        this.addEventListener('loadend', () => {
 | 
					                        this.addEventListener('loadend', () => {
 | 
				
			||||||
                            TestingBehatBlocking.unblock(key);
 | 
					                            TestingBehatBlocking.unblock(key);
 | 
				
			||||||
                        });
 | 
					                        });
 | 
				
			||||||
 | 
					                    } else {
 | 
				
			||||||
 | 
					                        const realSend = this.send;
 | 
				
			||||||
 | 
					                        this.send = (...args) => {
 | 
				
			||||||
 | 
					                            try {
 | 
				
			||||||
 | 
					                                return realSend.apply(this, args);
 | 
				
			||||||
 | 
					                            } finally {
 | 
				
			||||||
 | 
					                                TestingBehatBlocking.unblock(key);
 | 
				
			||||||
 | 
					                            }
 | 
				
			||||||
 | 
					                        };
 | 
				
			||||||
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    return realOpen.apply(this, args);
 | 
					                    return realOpen.apply(this, args);
 | 
				
			||||||
                } catch (error) {
 | 
					                } catch (error) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user