MCPcopy Index your code
hub / github.com/unconed/TermKit / mockShell

Function mockShell

Node/test.js:69–90  ·  view source on GitHub ↗

* Helper: run worker commands on a shell.

(flow, callback)

Source from the content-addressed store, hash-verified

67 * Helper: run worker commands on a shell.
68 */
69function mockShell(flow, callback) {
70 var messages = [], success = true, i = 0;
71
72 var stdin = new EventEmitter(),
73 stdout = new EventEmitter();
74
75 stdout.write = function (data) {
76 messages.push(JSON.parse(data.substring(0, data.length - 1)));
77 };
78
79 var p = new processor.processor(stdin, stdout);
80 for (i in flow) (function (message) {
81 setTimeout(function () {
82 stdin.emit('data', JSON.stringify(message) + '\u0000');
83 }, i * 100);
84 })(flow[i]);
85
86 setTimeout(track(function () {
87 callback(messages, success);
88 stdin.emit('end');
89 }), i * 100 + 1000);
90}
91
92/**
93 * Test termkit handshake.

Callers 3

testCommandsFunction · 0.85
testAutocompleteFunction · 0.85
testPipeFunction · 0.85

Calls 1

callbackFunction · 0.50

Tested by

no test coverage detected