()
| 14 | } |
| 15 | |
| 16 | function createServer() { |
| 17 | const behavior = plan[index++] || { type: 'success' } |
| 18 | const handlers = {} |
| 19 | |
| 20 | return { |
| 21 | on(event, handler) { |
| 22 | handlers[event] = handler |
| 23 | }, |
| 24 | listen(port, callback) { |
| 25 | state.listenPorts.push(port) |
| 26 | setImmediate(() => { |
| 27 | if (behavior.type === 'success') { |
| 28 | callback() |
| 29 | return |
| 30 | } |
| 31 | if (handlers.error) { |
| 32 | handlers.error({ code: behavior.code || 'EADDRINUSE' }) |
| 33 | } |
| 34 | }) |
| 35 | }, |
| 36 | close() { |
| 37 | state.closeCount += 1 |
| 38 | }, |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | return { createServer, state } |
| 43 | } |
no outgoing calls
no test coverage detected