@@ -6,6 +6,7 @@ import { IOSLogParserService } from "../../lib/services/ios-log-parser-service";
66import { IOSSimulatorLogProvider } from "../../lib/common/mobile/ios/simulator/ios-simulator-log-provider" ;
77import { Yok } from "../../lib/common/yok" ;
88import { EventEmitter } from "events" ;
9+ import * as sinon from "sinon" ;
910
1011class DeviceApplicationManagerMock extends EventEmitter { }
1112
@@ -50,6 +51,7 @@ function createTestInjector() {
5051 projectName : "test" ,
5152 projectId : appId
5253 } ) ;
54+ injector . register ( "iOSNotification" , DeviceApplicationManagerMock ) ;
5355
5456 return injector ;
5557}
@@ -82,11 +84,17 @@ function getMultilineDebuggerPortMessage(port: number) {
8284
8385describe ( "iOSDebuggerPortService" , ( ) => {
8486 let injector : IInjector , iOSDebuggerPortService : IIOSDebuggerPortService , iosDeviceOperations : IIOSDeviceOperations ;
87+ let clock : sinon . SinonFakeTimers = null ;
8588
8689 beforeEach ( ( ) => {
8790 injector = createTestInjector ( ) ;
8891 iOSDebuggerPortService = injector . resolve ( "iOSDebuggerPortService" ) ;
8992 iosDeviceOperations = injector . resolve ( "iosDeviceOperations" ) ;
93+ clock = sinon . useFakeTimers ( ) ;
94+ } ) ;
95+
96+ afterEach ( ( ) => {
97+ clock . restore ( ) ;
9098 } ) ;
9199
92100 function emitDeviceLog ( message : string ) {
@@ -142,7 +150,9 @@ describe("iOSDebuggerPortService", () => {
142150 emitDeviceLog ( getDebuggerPortMessage ( testCase . emittedPort ) ) ;
143151 }
144152
145- const port = await iOSDebuggerPortService . getPort ( { deviceId : deviceId , appId : appId } ) ;
153+ const promise = iOSDebuggerPortService . getPort ( { deviceId : deviceId , appId : appId } ) ;
154+ clock . tick ( 10000 ) ;
155+ const port = await promise ;
146156 assert . deepEqual ( port , testCase . emittedPort ) ;
147157 } ) ;
148158 it ( `${ testCase . name } for multiline debugger port message.` , async ( ) => {
@@ -154,7 +164,9 @@ describe("iOSDebuggerPortService", () => {
154164 emitDeviceLog ( getMultilineDebuggerPortMessage ( testCase . emittedPort ) ) ;
155165 }
156166
157- const port = await iOSDebuggerPortService . getPort ( { deviceId : deviceId , appId : appId } ) ;
167+ const promise = iOSDebuggerPortService . getPort ( { deviceId : deviceId , appId : appId } ) ;
168+ clock . tick ( 10000 ) ;
169+ const port = await promise ;
158170 assert . deepEqual ( port , testCase . emittedPort ) ;
159171 } ) ;
160172 } ) ;
0 commit comments