Comparing version 0.0.1 to 0.1.0
var utils = require('./utils'); | ||
var proto = require('./proto'); | ||
var wechat = require('wechat'); | ||
@@ -13,3 +14,6 @@ exports = module.exports = createBot; | ||
bot.stack = []; | ||
bot.wechat = function createWechat(token) { | ||
return wechat(token, bot); | ||
}; | ||
return bot; | ||
} |
{ | ||
"name": "wechat-bot", | ||
"version": "0.0.1", | ||
"version": "0.1.0", | ||
"description": "middleware framework for creating wechat bot", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -5,3 +5,3 @@ # wechat-bot | ||
[![build status](https://secure.travis-ci.org/rogerz/wechat-bot.png)](http://travis-ci.org/rogerz/wechat-bot) | ||
[![build status](https://secure.travis-ci.org/wechat-bots/wechat-bot.png)](http://travis-ci.org/wechat-bots/wechat-bot) | ||
@@ -8,0 +8,0 @@ ## Installation |
@@ -17,14 +17,17 @@ var should = require('chai').should(); | ||
}); | ||
var info = { | ||
sp: 'sp', | ||
user: 'user', | ||
type: 'text', | ||
text: 'test' | ||
}; | ||
var app; | ||
var app = connect(); | ||
app.use(connect.query()); | ||
app.use('/wechat', wechat('some token', bot)); | ||
beforeEach(function () { | ||
app = connect(); | ||
app.use(connect.query()); | ||
}); | ||
it('should work', function (done) { | ||
var info = { | ||
sp: 'sp', | ||
user: 'user', | ||
type: 'text', | ||
text: 'test' | ||
}; | ||
it('should be used as wechat handler', function (done) { | ||
app.use('/wechat', wechat('some token', bot)); | ||
request(app) | ||
@@ -41,2 +44,16 @@ .post('/wechat' + tail()) | ||
}); | ||
it('should create shortcut of wechat', function (done) { | ||
app.use('/wechat', bot.wechat('some token')); | ||
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('hello'); | ||
done(); | ||
}); | ||
}); | ||
}); |
10777
289