MCPcopy Index your code
hub / github.com/hackmdio/codimd / makeMockSocket

Function makeMockSocket

test/realtime/utils.js:6–34  ·  view source on GitHub ↗
(headers, query)

Source from the content-addressed store, hash-verified

4const path = require('path')
5
6function makeMockSocket (headers, query) {
7 const broadCastChannelCache = {}
8 return {
9 id: Math.round(Math.random() * 10000),
10 request: {
11 user: {}
12 },
13 handshake: {
14 headers: Object.assign({}, headers),
15 query: Object.assign({}, query)
16 },
17 on: sinon.fake(),
18 emit: sinon.fake(),
19 broadCastChannelCache: {},
20 broadcast: {
21 to: (channel) => {
22 if (!broadCastChannelCache[channel]) {
23 broadCastChannelCache[channel] = {
24 channel: channel,
25 emit: sinon.fake()
26 }
27 }
28 return broadCastChannelCache[channel]
29 }
30 },
31 disconnect: sinon.fake(),
32 rooms: []
33 }
34}
35
36function removeModuleFromRequireCache (modulePath) {
37 delete require.cache[require.resolve(modulePath)]

Calls

no outgoing calls

Tested by

no test coverage detected