Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
calidion committed Nov 16, 2015
1 parent 508bde1 commit e171872
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions test/test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,52 @@
'use strict';
var assert = require('assert');
var nodeWeixinJssdk = require('../');
var config = require('node-weixin-config');
var auth = require('node-weixin-auth');

var app = {
id: process.env.APP_ID,
secret: process.env.APP_SECRET,
token: process.env.APP_TOKEN
};

config.app.init(app);

var url = 'http://wx.t1bao.com/pay';


describe('node-weixin-jssdk node module', function () {
it('should be able to get jsapi_ticket', function (done) {
var config = require('node-weixin-config');
var auth = require('node-weixin-auth');

var url = 'http://wx.t1bao.com/pay';
config.app.init(app);


nodeWeixinJssdk.prepare(app, auth, url, function(error, data) {
assert.equal(true, !error);
assert.equal(true, app.jssdk.passed === false);
assert.equal(true, data.appId === app.id);
assert.equal(true, data.signature.length > 1);
assert.equal(true, data.nonceStr.length > 1);
assert.equal(true, data.timestamp.length > 1);
done();
});
});

it('should be able to get jsapi_ticket', function (done) {
nodeWeixinJssdk.prepare(app, auth, url, function(error, data) {
assert.equal(true, !error);
assert.equal(true, app.jssdk.passed === true);
assert.equal(true, data.appId === app.id);
assert.equal(true, data.signature.length > 1);
assert.equal(true, data.nonceStr.length > 1);
assert.equal(true, data.timestamp.length > 1);
done();
});
});

it('should be fail to get jsapi_ticket', function (done) {
nodeWeixinJssdk.prepare({}, auth, url, function(error) {
assert.equal(true, error);
done();
});
});
});

0 comments on commit e171872

Please sign in to comment.