| 242 | } |
| 243 | |
| 244 | class MockWatchHost { |
| 245 | nextTimeoutListenerId = 1; |
| 246 | timeoutListeners: {[id: string]: () => void} = {}; |
| 247 | fileChangeListeners: Array<((event: FileChangeEvent, fileName: string) => void) | null> = []; |
| 248 | diagnostics: ts.Diagnostic[] = []; |
| 249 | constructor(public config: ng.ParsedConfiguration) {} |
| 250 | |
| 251 | reportDiagnostics(diags: readonly ts.Diagnostic[]) { |
| 252 | this.diagnostics.push(...diags); |
| 253 | } |
| 254 | readConfiguration() { |
| 255 | return this.config; |
| 256 | } |
| 257 | createCompilerHost(options: ng.CompilerOptions) { |
| 258 | return ng.createCompilerHost({options}); |
| 259 | } |
| 260 | createEmitCallback() { |
| 261 | return undefined; |
| 262 | } |
| 263 | onFileChange( |
| 264 | options: ng.CompilerOptions, |
| 265 | listener: (event: FileChangeEvent, fileName: string) => void, |
| 266 | ready: () => void, |
| 267 | ) { |
| 268 | const id = this.fileChangeListeners.length; |
| 269 | this.fileChangeListeners.push(listener); |
| 270 | ready(); |
| 271 | return { |
| 272 | close: () => (this.fileChangeListeners[id] = null), |
| 273 | }; |
| 274 | } |
| 275 | setTimeout(callback: () => void): any { |
| 276 | const id = this.nextTimeoutListenerId++; |
| 277 | this.timeoutListeners[id] = callback; |
| 278 | return id; |
| 279 | } |
| 280 | clearTimeout(timeoutId: any): void { |
| 281 | delete this.timeoutListeners[timeoutId]; |
| 282 | } |
| 283 | flushTimeouts() { |
| 284 | const listeners = this.timeoutListeners; |
| 285 | this.timeoutListeners = {}; |
| 286 | Object.keys(listeners).forEach((id) => listeners[id]()); |
| 287 | } |
| 288 | triggerFileChange(event: FileChangeEvent, fileName: string) { |
| 289 | this.fileChangeListeners.forEach((listener) => { |
| 290 | if (listener) { |
| 291 | listener(event, fileName); |
| 292 | } |
| 293 | }); |
| 294 | this.flushTimeouts(); |
| 295 | } |
| 296 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…