MCPcopy Create free account
hub / github.com/unconed/TermKit / mockClient

Function mockClient

Node/test.js:41–64  ·  view source on GitHub ↗

* Helper: simulate a client connection on the router.

(flow, callback)

Source from the content-addressed store, hash-verified

39 * Helper: simulate a client connection on the router.
40 */
41function mockClient(flow, callback) {
42 var client = new EventEmitter();
43 var messages = [], success = true, i;
44
45 client.send = function (message) {
46 messages.push(message);
47 };
48
49 client.disconnect = function (message) {
50 success = false;
51 };
52
53 var r = new router.router(client);
54 for (i in flow) (function (message) {
55 setTimeout(function () {
56 client.emit('message', message);
57 }, i * 100);
58 })(flow[i]);
59
60 setTimeout(track(function () {
61 callback(messages, success);
62 r.disconnect();
63 }), i * 100 + 500);
64}
65
66/**
67 * Helper: run worker commands on a shell.

Callers 2

testHandshakeFunction · 0.85
testSessionFunction · 0.85

Calls 1

callbackFunction · 0.50

Tested by

no test coverage detected