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

Function testAutocomplete

Node/test.js:272–302  ·  view source on GitHub ↗

* Test autocompletion handler.

(assert)

Source from the content-addressed store, hash-verified

270 * Test autocompletion handler.
271 */
272function testAutocomplete(assert) {
273 var auto = new autocomplete.autocomplete(), c;
274
275 mockShell([
276 { query: 7, method: 'shell.autocomplete', args: { tokens: [ 'c' ], offset: 0 } },
277 ], function (messages, success) {
278 /*
279 var i, j;
280 for (i in messages) {
281 for (j in messages[i].args.matches) {
282 console.log(messages[i].args.matches[j]);
283 }
284 }
285 */
286 var last = messages[messages.length - 1];
287 assert(last && last.success && last.answer == 7, "Autocomplete c command");
288 });
289
290 auto.process(process.cwd(), [], [ 'c' ], 0, function (m) {
291 assert(m && m.length == 3 &&
292 m[0].label == 'cat' && m[0].type == 'command' &&
293 m[1].label == 'cd' && m[1].type == 'command' &&
294 m[2].label == 'clear' && m[2].type == 'command', "Autocomplete c command");
295 });
296
297 auto.process(process.cwd(), [], [ 'cat', 'test.j' ], 1, function (m) {
298 assert(m && m.length == 1 &&
299 m[0].label == 'test.js' && m[0].type == 'file', "Autocomplete test.j filename");
300 });
301
302}
303
304/**
305 * Test misc utilties.

Callers

nothing calls this directly

Calls 2

mockShellFunction · 0.85
assertFunction · 0.85

Tested by

no test coverage detected