* Test autocompletion handler.
(assert)
| 270 | * Test autocompletion handler. |
| 271 | */ |
| 272 | function 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. |