(doInstance: UserConnectionDO, connectionId: string)
| 128 | result.set(key, value as T); |
| 129 | } |
| 130 | } |
| 131 | return result; |
| 132 | }), |
| 133 | // The glanceable deferral reads the current alarm before re-arming it, so |
| 134 | // the fake must model the alarm rather than return `undefined`. |
| 135 | getAlarm: vi.fn(async () => alarmTime), |
| 136 | setAlarm: vi.fn(async (scheduledTime: number | Date) => { |
| 137 | alarmTime = typeof scheduledTime === 'number' ? scheduledTime : scheduledTime.getTime(); |
| 138 | }), |
| 139 | }; |
| 140 | } |
| 141 | |
| 142 | function createMockCtx() { |
| 143 | const sockets: MockWS[] = []; |
| 144 | const storage = makeStorageFake(); |
| 145 | return { |
| 146 | sockets, |
| 147 | storage, |
| 148 | addSocket(ws: MockWS) { |
| 149 | sockets.push(ws); |
| 150 | }, |
| 151 | removeSocket(ws: MockWS) { |
| 152 | const idx = sockets.indexOf(ws); |
| 153 | if (idx !== -1) sockets.splice(idx, 1); |
| 154 | }, |
| 155 | build() { |
| 156 | return { |
no test coverage detected