UNPKG

23.7 kBtext/coffeescriptView Raw
1sinon = require('sinon')
2_ = require('lodash')
3chai = require('chai')
4chai.use(require('sinon-chai'))
5expect = chai.expect
6Signature = require('../lib/signature')
7Parameter = require('../lib/parameter')
8settings = require('../lib/settings')
9utils = require('../lib/utils')
10
11describe 'Signature:', ->
12
13 describe '#constructor()', ->
14
15 it 'should throw an error if no signature', ->
16 expect ->
17 new Signature()
18 .to.throw(Error)
19
20 it 'should throw an error if signature is not a string', ->
21 expect ->
22 new Signature([ 1, 2, 3 ])
23 .to.throw(Error)
24
25 it 'should store each parameter', ->
26 signature = new Signature('foo bar baz')
27 expect(signature.parameters).to.have.length(3)
28
29 it 'should store each parameter as instance of Parameter', ->
30 signature = new Signature('foo bar baz')
31 for parameter in signature.parameters
32 expect(parameter).to.be.an.instanceof(Parameter)
33
34 it 'should throw an error if the variadic parameter is not the last one', ->
35 expect ->
36 new Signature('foo <bar...> <baz>')
37 .to.throw(Error)
38
39 it 'should throw an error if there are multiple variadic parameters', ->
40 expect ->
41 new Signature('foo <bar...> <baz...>')
42 .to.throw(Error)
43
44 it 'should throw an error if there are multiple stdin parameters', ->
45 expect ->
46 new Signature('foo <|bar> [|baz]')
47 .to.throw('Signature can only contain one stdin parameter')
48
49 it 'should throw an error if the stdin parameter is not the last one', ->
50 expect ->
51 new Signature('foo <|bar> <baz>')
52 .to.throw('The stdin parameter should be the last one')
53
54 describe '#_addParameter()', ->
55
56 it 'should add the parameter to the class', ->
57 signature = new Signature('foo')
58 expect(signature.parameters).to.have.length(1)
59 signature._addParameter('<bar>')
60 expect(signature.parameters).to.have.length(2)
61 lastParameter = _.last(signature.parameters)
62
63 expect(lastParameter.getValue()).to.equal('bar')
64 expect(lastParameter.getType()).to.equal('parameter')
65 expect(lastParameter.isRequired()).to.equal(true)
66 expect(lastParameter.isVariadic()).to.equal(false)
67
68 describe '#hasParameters()', ->
69
70 it 'should return false if no parameters', ->
71 signature = new Signature('foo')
72 expect(signature.hasParameters()).to.be.false
73
74 it 'should return true if required parameters', ->
75 signature = new Signature('foo <bar>')
76 expect(signature.hasParameters()).to.be.true
77
78 it 'should return true if optional parameters', ->
79 signature = new Signature('foo [bar]')
80 expect(signature.hasParameters()).to.be.true
81
82 it 'should return true if multiple required parameters', ->
83 signature = new Signature('foo <bar> <baz>')
84 expect(signature.hasParameters()).to.be.true
85
86 it 'should return true if optional parameters', ->
87 signature = new Signature('foo [bar] [baz]')
88 expect(signature.hasParameters()).to.be.true
89
90 it 'should return true if variadic required parameters', ->
91 signature = new Signature('foo <bar...>')
92 expect(signature.hasParameters()).to.be.true
93
94 it 'should return true variadic parameters', ->
95 signature = new Signature('foo [bar...]')
96 expect(signature.hasParameters()).to.be.true
97
98 describe '#hasVariadicParameters', ->
99
100 it 'should return false if no parameters', ->
101 signature = new Signature('foo')
102 expect(signature.hasVariadicParameters()).to.be.false
103
104 it 'should return false if required parameters', ->
105 signature = new Signature('foo <bar>')
106 expect(signature.hasVariadicParameters()).to.be.false
107
108 it 'should return false if optional parameters', ->
109 signature = new Signature('foo [bar]')
110 expect(signature.hasVariadicParameters()).to.be.false
111
112 it 'should return false if multiple required parameters', ->
113 signature = new Signature('foo <bar> <baz>')
114 expect(signature.hasVariadicParameters()).to.be.false
115
116 it 'should return false if optional parameters', ->
117 signature = new Signature('foo [bar] [baz]')
118 expect(signature.hasVariadicParameters()).to.be.false
119
120 it 'should return true if variadic required parameters', ->
121 signature = new Signature('foo <bar...>')
122 expect(signature.hasVariadicParameters()).to.be.true
123
124 it 'should return true variadic parameters', ->
125 signature = new Signature('foo [bar...]')
126 expect(signature.hasVariadicParameters()).to.be.true
127
128 describe '#allowsStdin()', ->
129
130 it 'should return false if no parameters', ->
131 signature = new Signature('foo')
132 expect(signature.allowsStdin()).to.be.false
133
134 it 'should return false if no stdin parameter', ->
135 signature = new Signature('foo <bar>')
136 expect(signature.allowsStdin()).to.be.false
137
138 it 'should return false if required variadic parameter', ->
139 signature = new Signature('foo <bar...>')
140 expect(signature.allowsStdin()).to.be.false
141
142 it 'should return false if optional variadic parameter', ->
143 signature = new Signature('foo [bar...]')
144 expect(signature.allowsStdin()).to.be.false
145
146 it 'should return true if one optional stdin parameter', ->
147 signature = new Signature('foo [|bar]')
148 expect(signature.allowsStdin()).to.be.true
149
150 it 'should return true if one required stdin parameter', ->
151 signature = new Signature('foo <|bar>')
152 expect(signature.allowsStdin()).to.be.true
153
154 it 'should return true if one non stdin parameter and one stdin parameter', ->
155 signature = new Signature('foo <bar> <|baz>')
156 expect(signature.allowsStdin()).to.be.true
157
158 describe '#toString()', ->
159
160 it 'should convert a signature to string', ->
161 signature = new Signature('foo <bar> [baz...]')
162 expect(signature.toString()).to.equal('foo <bar> [baz...]')
163
164 it 'should convert a wildcard to string', ->
165 signature = new Signature('*')
166 expect(signature.toString()).to.equal('*')
167
168 describe '#isWildcard()', ->
169
170 it 'should return true if it is wildcard', ->
171 signature = new Signature(settings.signatures.wildcard)
172 expect(signature.isWildcard()).to.be.true
173
174 it 'should return false if it is not wildcard', ->
175 signature = new Signature('foo <bar>')
176 expect(signature.isWildcard()).to.be.false
177
178 it 'should return false if it starts with a wildcard', ->
179 signature = new Signature("#{settings.signatures.wildcard} foo")
180 expect(signature.isWildcard()).to.be.false
181
182 describe '#matches()', ->
183
184 it 'should match agains a wildcard', (done) ->
185 signature = new Signature('*')
186 signature.matches 'foo hello', (result) ->
187 expect(result).to.be.true
188 done()
189
190 describe 'given one word signatures', ->
191
192 it 'should return true if matches', (done) ->
193 signature = new Signature('foo <bar>')
194 signature.matches 'foo hello', (result) ->
195 expect(result).to.be.true
196 done()
197
198 it 'should return true if optional parameter is missing', (done) ->
199 signature = new Signature('foo [bar]')
200 signature.matches 'foo', (result) ->
201 expect(result).to.be.true
202 done()
203
204 it 'should return true if required parameter is missing', (done) ->
205 signature = new Signature('foo <bar>')
206 signature.matches 'foo', (result) ->
207 expect(result).to.be.true
208 done()
209
210 it 'should return false if no match', (done) ->
211 signature = new Signature('foo <hello>')
212 signature.matches 'bar hello', (result) ->
213 expect(result).to.be.false
214 done()
215
216 it 'should return false if signature exceeds command', (done) ->
217 signature = new Signature('app <id>')
218 signature.matches 'app rm 91', (result) ->
219 expect(result).to.be.false
220 done()
221
222 describe 'given multi word signatures', ->
223
224 it 'should return true if matches', (done) ->
225 signature = new Signature('foo bar <bar>')
226 signature.matches 'foo bar hello', (result) ->
227 expect(result).to.be.true
228 done()
229
230 describe 'given variadic signatures', ->
231
232 it 'should return true if matches', (done) ->
233 signature = new Signature('foo bar <bar...>')
234 signature.matches 'foo bar hello world baz', (result) ->
235 expect(result).to.be.true
236 done()
237
238 it 'should return true if missing optional variadic parameter', (done) ->
239 signature = new Signature('foo bar [bar...]')
240 signature.matches 'foo bar', (result) ->
241 expect(result).to.be.true
242 done()
243
244 it 'should return true if missing required variadic parameter', (done) ->
245 signature = new Signature('foo bar <bar...>')
246 signature.matches 'foo bar', (result) ->
247 expect(result).to.be.true
248 done()
249
250 describe '#compileParameters()', ->
251
252 describe 'given a wildcard', ->
253
254 beforeEach ->
255 @signature = new Signature(settings.signatures.wildcard)
256
257 it 'should return an empty object', (done) ->
258 @signature.compileParameters 'foo', (error, result) ->
259 expect(error).to.not.exist
260 expect(result).to.deep.equal({})
261 done()
262
263 describe 'given a signature with no parameters', ->
264
265 beforeEach ->
266 @signature = new Signature('foo')
267
268 it 'should return an empty object if it matches', (done) ->
269 @signature.compileParameters 'foo', (error, result) ->
270 expect(error).to.not.exist
271 expect(result).to.deep.equal({})
272 done()
273
274 describe 'given a signature with one required parameter', ->
275
276 beforeEach ->
277 @signature = new Signature('foo <bar>')
278
279 it 'should throw an error if prefix is different', (done) ->
280 @signature.compileParameters 'bar hello', (error, result) ->
281 expect(error).to.be.an.instanceof(Error)
282 expect(result).to.not.exist
283 done()
284
285 it 'should throw an error if command exceeds', (done) ->
286 @signature.compileParameters 'foo hello world', (error, result) ->
287 expect(error).to.be.an.instanceof(Error)
288 expect(result).to.not.exist
289 done()
290
291 it 'should throw an error if command misses parameter', (done) ->
292 @signature.compileParameters 'foo', (error, result) ->
293 expect(error).to.be.an.instanceof(Error)
294 expect(error.message).to.equal('Missing bar')
295 expect(result).to.not.exist
296 done()
297
298 it 'should return a single parameter if it matches', (done) ->
299 @signature.compileParameters 'foo hello', (error, result) ->
300 expect(error).to.not.exist
301 expect(result).to.deep.equal
302 bar: 'hello'
303 done()
304
305 describe 'given a signature with one optional parameter', ->
306
307 beforeEach ->
308 @signature = new Signature('foo [bar]')
309
310 it 'should throw an error if prefix is different', (done) ->
311 @signature.compileParameters 'bar hello', (error, result) ->
312 expect(error).to.be.an.instanceof(Error)
313 expect(result).to.not.exist
314 done()
315
316 it 'should throw an error if command exceeds', (done) ->
317 @signature.compileParameters 'foo hello world', (error, result) ->
318 expect(error).to.be.an.instanceof(Error)
319 expect(result).to.not.exist
320 done()
321
322 it 'should return an empty object if command misses parameter', (done) ->
323 @signature.compileParameters 'foo', (error, result) ->
324 expect(error).to.not.exist
325 expect(result).to.deep.equal({})
326 done()
327
328 it 'should return a single parameter if it matches', (done) ->
329 @signature.compileParameters 'foo hello', (error, result) ->
330 expect(error).to.not.exist
331 expect(result).to.deep.equal
332 bar: 'hello'
333 done()
334
335 describe 'given a command with a stdin required parameter', ->
336
337 beforeEach ->
338 @signature = new Signature('foo <|bar>')
339
340 describe 'if performStdin flag is false', ->
341
342 beforeEach ->
343 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
344
345 afterEach ->
346 @utilsGetStdinStub.restore()
347
348 it 'should not call getStdin', (done) ->
349 @signature.compileParameters 'foo', (error, result) =>
350 expect(@utilsGetStdinStub).to.not.have.been.called
351 done()
352 , false
353
354 describe 'if performStdin flag is true', ->
355
356 beforeEach ->
357 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
358 @utilsGetStdinStub.callsArgWithAsync(0, 'Hello World')
359
360 afterEach ->
361 @utilsGetStdinStub.restore()
362
363 it 'should call getStdin', (done) ->
364 @signature.compileParameters 'foo', (error, result) =>
365 expect(@utilsGetStdinStub).to.have.been.calledOnce
366 done()
367 , true
368
369 describe 'if performStdin flag is undefined', ->
370
371 beforeEach ->
372 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
373 @utilsGetStdinStub.callsArgWithAsync(0, 'Hello World')
374
375 afterEach ->
376 @utilsGetStdinStub.restore()
377
378 it 'should call getStdin', (done) ->
379 @signature.compileParameters 'foo', (error, result) =>
380 expect(@utilsGetStdinStub).to.have.been.calledOnce
381 done()
382
383 describe 'if stdin returns data', ->
384
385 beforeEach ->
386 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
387 @utilsGetStdinStub.callsArgWithAsync(0, 'Hello World')
388
389 afterEach ->
390 @utilsGetStdinStub.restore()
391
392 it 'should assign the parameter to the stdin output', (done) ->
393 @signature.compileParameters 'foo', (error, result) ->
394 expect(error).to.not.exist
395 expect(result).to.deep.equal
396 bar: 'Hello World'
397 done()
398
399 describe 'if stdin does not return data', ->
400
401 beforeEach ->
402 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
403 @utilsGetStdinStub.callsArgWithAsync(0, undefined)
404
405 afterEach ->
406 @utilsGetStdinStub.restore()
407
408 it 'should throw an error', (done) ->
409 @signature.compileParameters 'foo', (error, result) ->
410 expect(error).to.be.an.instanceof(Error)
411 expect(error.message).to.equal('Missing bar')
412 expect(result).to.not.exist
413 done()
414
415 describe 'given a command with a stdin optional parameter', ->
416
417 beforeEach ->
418 @signature = new Signature('foo [|bar]')
419
420 describe 'if stdin returns data', ->
421
422 beforeEach ->
423 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
424 @utilsGetStdinStub.callsArgWithAsync(0, 'Hello World')
425
426 afterEach ->
427 @utilsGetStdinStub.restore()
428
429 it 'should assign the parameter to the stdin output', (done) ->
430 @signature.compileParameters 'foo', (error, result) ->
431 expect(error).to.not.exist
432 expect(result).to.deep.equal
433 bar: 'Hello World'
434 done()
435
436 describe 'if stdin does not return data', ->
437
438 beforeEach ->
439 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
440 @utilsGetStdinStub.callsArgWithAsync(0, undefined)
441
442 afterEach ->
443 @utilsGetStdinStub.restore()
444
445 it 'should do nothing', (done) ->
446 @signature.compileParameters 'foo', (error, result) ->
447 expect(error).to.not.exist
448 expect(result).to.deep.equal({})
449 done()
450
451 describe 'given a signature with a required parameter and a required stdin parameter', ->
452
453 beforeEach ->
454 @signature = new Signature('foo <bar> <|baz>')
455
456 describe 'if stdin returns data', ->
457
458 beforeEach ->
459 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
460 @utilsGetStdinStub.callsArgWithAsync(0, 'Hello World')
461
462 afterEach ->
463 @utilsGetStdinStub.restore()
464
465 it 'should assign the parameter to the stdin output', (done) ->
466 @signature.compileParameters 'foo hello', (error, result) ->
467 expect(error).to.not.exist
468 expect(result).to.deep.equal
469 bar: 'hello'
470 baz: 'Hello World'
471 done()
472
473 describe 'if stdin does not return data', ->
474
475 beforeEach ->
476 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
477 @utilsGetStdinStub.callsArgWithAsync(0, undefined)
478
479 afterEach ->
480 @utilsGetStdinStub.restore()
481
482 it 'should throw an error', (done) ->
483 @signature.compileParameters 'foo hello', (error, result) ->
484 expect(error).to.be.an.instanceof(Error)
485 expect(error.message).to.equal('Missing baz')
486 expect(result).to.not.exist
487 done()
488
489 describe 'given a signature with a required parameter and an optional stdin parameter', ->
490
491 beforeEach ->
492 @signature = new Signature('foo <bar> [|baz]')
493
494 describe 'if stdin returns data', ->
495
496 beforeEach ->
497 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
498 @utilsGetStdinStub.callsArgWithAsync(0, 'Hello World')
499
500 afterEach ->
501 @utilsGetStdinStub.restore()
502
503 it 'should assign the parameter to the stdin output', (done) ->
504 @signature.compileParameters 'foo hello', (error, result) ->
505 expect(error).to.not.exist
506 expect(result).to.deep.equal
507 bar: 'hello'
508 baz: 'Hello World'
509 done()
510
511 describe 'if stdin does not return data', ->
512
513 beforeEach ->
514 @utilsGetStdinStub = sinon.stub(utils, 'getStdin')
515 @utilsGetStdinStub.callsArgWithAsync(0, undefined)
516
517 afterEach ->
518 @utilsGetStdinStub.restore()
519
520 it 'should do nothing', (done) ->
521 @signature.compileParameters 'foo hello', (error, result) ->
522 expect(error).to.not.exist
523 expect(result).to.deep.equal
524 bar: 'hello'
525 done()
526
527 describe 'given a signature with multiple required parameters', ->
528
529 beforeEach ->
530 @signature = new Signature('foo <bar> <baz>')
531
532 it 'should throw an error if prefix is different', (done) ->
533 @signature.compileParameters 'bar hello world', (error, result) ->
534 expect(error).to.be.an.instanceof(Error)
535 expect(result).to.not.exist
536 done()
537
538 it 'should throw an error if command exceeds', (done) ->
539 @signature.compileParameters 'foo hello world bar', (error, result) ->
540 expect(error).to.be.an.instanceof(Error)
541 expect(result).to.not.exist
542 done()
543
544 it 'should throw an error if command misses one parameter', (done) ->
545 @signature.compileParameters 'foo hello', (error, result) ->
546 expect(error).to.be.an.instanceof(Error)
547 expect(error.message).to.equal('Missing baz')
548 expect(result).to.not.exist
549 done()
550
551 it 'should throw an error if command misses both parameters', (done) ->
552 @signature.compileParameters 'foo', (error, result) ->
553 expect(error).to.be.an.instanceof(Error)
554 expect(error.message).to.equal('Missing bar')
555 expect(result).to.not.exist
556 done()
557
558 it 'should return both parameters if it matches', (done) ->
559 @signature.compileParameters 'foo hello world', (error, result) ->
560 expect(error).to.not.exist
561 expect(result).to.deep.equal
562 bar: 'hello'
563 baz: 'world'
564 done()
565
566 describe 'given a signature with mixed parameters', ->
567
568 beforeEach ->
569 @signature = new Signature('foo <bar> [baz]')
570
571 it 'should throw an error if prefix is different', (done) ->
572 @signature.compileParameters 'bar hello world', (error, result) ->
573 expect(error).to.be.an.instanceof(Error)
574 expect(result).to.not.exist
575 done()
576
577 it 'should throw an error if command exceeds', (done) ->
578 @signature.compileParameters 'foo hello world bar', (error, result) ->
579 expect(error).to.be.an.instanceof(Error)
580 expect(result).to.not.exist
581 done()
582
583 it 'should return one parameter if command misses one parameter', (done) ->
584 @signature.compileParameters 'foo hello', (error, result) ->
585 expect(error).to.not.exist
586 expect(result).to.deep.equal
587 bar: 'hello'
588 done()
589
590 it 'should throw an error if command misses both parameters', (done) ->
591 @signature.compileParameters 'foo', (error, result) ->
592 expect(error).to.be.an.instanceof(Error)
593 expect(error.message).to.equal('Missing bar')
594 expect(result).to.not.exist
595 done()
596
597 it 'should return both parameters if it matches', (done) ->
598 @signature.compileParameters 'foo hello world', (error, result) ->
599 expect(error).to.not.exist
600 expect(result).to.deep.equal
601 bar: 'hello'
602 baz: 'world'
603 done()
604
605 describe 'given a signature with a variadic required parameter', ->
606
607 beforeEach ->
608 @signature = new Signature('foo <bar...>')
609
610 it 'should throw an error if prefix is different', (done) ->
611 @signature.compileParameters 'bar hello world', (error, result) ->
612 expect(error).to.be.an.instanceof(Error)
613 expect(result).to.not.exist
614 done()
615
616 it 'should all parameters together if command exceeds', (done) ->
617 @signature.compileParameters 'foo hello world bar', (error, result) ->
618 expect(error).to.not.exist
619 expect(result).to.deep.equal
620 bar: 'hello world bar'
621 done()
622
623 it 'should throw an error if command misses the parameter', (done) ->
624 @signature.compileParameters 'foo', (error, result) ->
625 expect(error).to.be.an.instanceof(Error)
626 expect(error.message).to.equal('Missing bar')
627 expect(result).to.not.exist
628 done()
629
630 it 'should return all parameters together if it matches', (done) ->
631 @signature.compileParameters 'foo hello world', (error, result) ->
632 expect(error).to.not.exist
633 expect(result).to.deep.equal
634 bar: 'hello world'
635 done()
636
637 describe 'given a signature with a variadic optional parameter', ->
638
639 beforeEach ->
640 @signature = new Signature('foo [bar...]')
641
642 it 'should throw an error if prefix is different', (done) ->
643 @signature.compileParameters 'bar hello world', (error, result) ->
644 expect(error).to.be.an.instanceof(Error)
645 expect(result).to.not.exist
646 done()
647
648 it 'should all parameters together if command exceeds', (done) ->
649 @signature.compileParameters 'foo hello world bar', (error, result) ->
650 expect(error).to.not.exist
651 expect(result).to.deep.equal
652 bar: 'hello world bar'
653 done()
654
655 it 'should return an empty object if command misses the parameter', (done) ->
656 @signature.compileParameters 'foo', (error, result) ->
657 expect(error).to.not.exist
658 expect(result).to.deep.equal({})
659 done()
660
661 it 'should return all parameters together if it matches', (done) ->
662 @signature.compileParameters 'foo hello world', (error, result) ->
663 expect(error).to.not.exist
664 expect(result).to.deep.equal
665 bar: 'hello world'
666 done()
667
668 describe 'given number commands', ->
669
670 it 'should parse the numbers automatically', (done) ->
671 signature = new Signature('foo <bar>')
672 signature.compileParameters 'foo 19', (error, result) ->
673 expect(error).to.not.exist
674 expect(result).to.deep.equal
675 bar: 19
676 done()
677
678 it 'should match with a string that starts with a number', (done) ->
679 signature = new Signature('<foo>')
680 signature.compileParameters '1bar', (error, result) ->
681 expect(error).to.not.exist
682 expect(result).to.deep.equal(foo: '1bar')
683 done()
684
685 describe 'given path commands', ->
686
687 it 'should be able to parse absolute paths', (done) ->
688 signature = new Signature('foo <bar>')
689 signature.compileParameters 'foo /Users/me/foo/bar', (error, result) ->
690 expect(error).to.not.exist
691 expect(result).to.deep.equal
692 bar: '/Users/me/foo/bar'
693 done()
694
695 it 'should be able to parse relative paths', (done) ->
696 signature = new Signature('foo <bar>')
697 signature.compileParameters 'foo ../hello/world', (error, result) ->
698 expect(error).to.not.exist
699 expect(result).to.deep.equal
700 bar: '../hello/world'
701 done()
702
703 it 'should be able to parse home relative paths', (done) ->
704 signature = new Signature('foo <bar>')
705 signature.compileParameters 'foo ~/.ssh/id_rsa.pub', (error, result) ->
706 expect(error).to.not.exist
707 expect(result).to.deep.equal
708 bar: '~/.ssh/id_rsa.pub'
709 done()
710
711 describe 'given quoted multi word command words', ->
712
713 it 'should parse single quoted multi words correctly', (done) ->
714 signature = new Signature('foo <bar>')
715 signature.compileParameters 'foo \'hello world\'', (error, result) ->
716 expect(error).to.not.exist
717 expect(result).to.deep.equal
718 bar: 'hello world'
719 done()
720
721 it 'should parse double quoted multi words correctly', (done) ->
722 signature = new Signature('foo <bar>')
723 signature.compileParameters 'foo "hello world"', (error, result) ->
724 expect(error).to.not.exist
725 expect(result).to.deep.equal
726 bar: 'hello world'
727 done()