@@ -6,6 +6,7 @@ import { IOSLogParserService } from "../../lib/services/ios-log-parser-service";
6
6
import { IOSSimulatorLogProvider } from "../../lib/common/mobile/ios/simulator/ios-simulator-log-provider" ;
7
7
import { Yok } from "../../lib/common/yok" ;
8
8
import { EventEmitter } from "events" ;
9
+ import * as sinon from "sinon" ;
9
10
10
11
class DeviceApplicationManagerMock extends EventEmitter { }
11
12
@@ -50,6 +51,7 @@ function createTestInjector() {
50
51
projectName : "test" ,
51
52
projectId : appId
52
53
} ) ;
54
+ injector . register ( "iOSNotification" , DeviceApplicationManagerMock ) ;
53
55
54
56
return injector ;
55
57
}
@@ -82,11 +84,17 @@ function getMultilineDebuggerPortMessage(port: number) {
82
84
83
85
describe ( "iOSDebuggerPortService" , ( ) => {
84
86
let injector : IInjector , iOSDebuggerPortService : IIOSDebuggerPortService , iosDeviceOperations : IIOSDeviceOperations ;
87
+ let clock : sinon . SinonFakeTimers = null ;
85
88
86
89
beforeEach ( ( ) => {
87
90
injector = createTestInjector ( ) ;
88
91
iOSDebuggerPortService = injector . resolve ( "iOSDebuggerPortService" ) ;
89
92
iosDeviceOperations = injector . resolve ( "iosDeviceOperations" ) ;
93
+ clock = sinon . useFakeTimers ( ) ;
94
+ } ) ;
95
+
96
+ afterEach ( ( ) => {
97
+ clock . restore ( ) ;
90
98
} ) ;
91
99
92
100
function emitDeviceLog ( message : string ) {
@@ -142,7 +150,9 @@ describe("iOSDebuggerPortService", () => {
142
150
emitDeviceLog ( getDebuggerPortMessage ( testCase . emittedPort ) ) ;
143
151
}
144
152
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 ;
146
156
assert . deepEqual ( port , testCase . emittedPort ) ;
147
157
} ) ;
148
158
it ( `${ testCase . name } for multiline debugger port message.` , async ( ) => {
@@ -154,7 +164,9 @@ describe("iOSDebuggerPortService", () => {
154
164
emitDeviceLog ( getMultilineDebuggerPortMessage ( testCase . emittedPort ) ) ;
155
165
}
156
166
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 ;
158
170
assert . deepEqual ( port , testCase . emittedPort ) ;
159
171
} ) ;
160
172
} ) ;
0 commit comments