修改单元测试

This commit is contained in:
lizheming
2018-12-16 23:55:46 +08:00
parent 93a5d6a792
commit 5f358b0cf9
+17 -28
View File
@@ -34,35 +34,24 @@ const MESSAGE = 'test for message';
// mock.stopAll();
// });
test('get wechat corp access token', async t => {
t.plan(3);
// test('get wechat corp access token', async t => {
// t.plan(2);
// mock('request-promise-native', obj => {
// t.deepEqual(obj, {
// url: 'https://qyapi.weixin.qq.com/cgi-bin/gettoken',
// qs: {
// corpid: 111,
// corpsecret: 222
// },
// json: true
// });
mock('process', {
env: {
PLUGIN_CORPID: 111,
PLUGIN_CORP_SECRET: 222,
PLUGIN_TITLE: TITLE,
PLUGIN_MESSAGE: MESSAGE
}
});
mock('request-promise-native', obj => {
if (obj.url.includes('gettoken')) {
t.deepEqual(obj, {
url: 'https://qyapi.weixin.qq.com/cgi-bin/gettoken',
qs: {
corpid: 111,
corpsecret: 222
},
json: true
});
}
return Promise.resolve({ access_token: 1234 });
});
const wechat = mock.reRequire('./index');
t.is(1234, await wechat.getAccessToken());
mock.stopAll();
});
// return Promise.resolve({ access_token: 1234 });
// });
// const plugin = mock.reRequire('./plugin');
// t.is(1234, await plugin.getAccessToken(111, 222));
// mock.stopAll();
// });
test('send wechat with corp id', async t => {
mock('process', {