forked from node-webot/wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist2.test.js
65 lines (58 loc) · 1.48 KB
/
list2.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
require('should');
var List = require('../').List;
var request = require('supertest');
var template = require('./support').template;
var tail = require('./support').tail;
var connect = require('connect');
var wechat = require('../');
var app = connect();
app.use(connect.query());
app.use(connect.cookieParser());
app.use(connect.session({secret: 'keyboard cat', cookie: {maxAge: 60000}}));
app.use('/wechat', wechat('some token', function (req, res, next) {
// 微信输入信息都在req.weixin上
var info = req.weixin;
if (info.Content === 'list') {
res.wait('view');
}
}));
describe('list', function() {
it('should ok with list', function (done) {
List.add('view', [
['回复{c}查看我的性取向', '这样的事情怎么好意思告诉你啦- -']
]);
var info = {
sp: 'test',
user: 'test',
type: 'text',
text: 'list'
};
request(app)
.post('/wechat' + tail())
.send(template(info))
.expect(200)
.end(function (err, res) {
if (err) {
return done(err);
}
info = {
sp: 'test',
user: 'test',
type: 'text',
text: 'c'
};
request(app)
.post('/wechat' + tail())
.send(template(info))
.expect(200)
.end(function(err, res){
if (err) {
return done(err);
}
var body = res.text.toString();
body.should.include('这样的事情怎么好意思告诉你啦');
done();
});
});
});
});