UNPKG

1.19 kBJavaScriptView Raw
1/* global describe, it, before, beforeEach, after, afterEach */
2var should = require('should');
3var Waif = require('../');
4var send = require('../send');
5
6describe('send a response', function() {
7 var waif = null;
8
9 before(function() {
10 waif = Waif.createInstance();
11 waif('ping')
12 .use(send, 'pong')
13 .listen();
14
15 waif('json')
16 .use(send, {msg: 'ok'})
17 .listen();
18
19 waif('helper')
20 .send('/helper', {msg: 'works'})
21 .listen();
22
23 waif.start();
24 });
25
26 after(function() { waif.stop(); });
27
28 it('can send pong', function(doneFn) {
29 var ping = waif('ping');
30
31 ping(test);
32
33 function test(err, resp, body) {
34 should.not.exist(err);
35 body.should.equal('pong');
36 doneFn();
37 }
38 });
39
40
41 it('can send json', function(doneFn) {
42 var ping = waif('json');
43
44 ping(test);
45
46 function test(err, resp, body) {
47 body.should.have.property('msg', 'ok');
48 doneFn();
49 }
50 });
51
52 it('can use helper method', function(doneFn) {
53 var helper = waif('helper');
54
55 helper('helper', test);
56
57 function test(err, resp, body) {
58 body.should.have.property('msg', 'works');
59 doneFn();
60 }
61 });
62});
63