/** * geetest验证码单元测试 * * @author CaiAoLin * @date 2017/10/19 * @version */ 'use strict'; const { app, assert } = require('egg-mock/bootstrap'); const Captcha = require('../../../app/lib/captcha'); describe('test/app/lib/captcha.test.js', () => { it('captcha register', function* () { // 创建 ctx const ctx = app.mockContext({ session: {}, }); const captcha = new Captcha(app); const response = yield captcha.register(ctx); assert(response !== ''); assert(typeof response === 'object'); assert(response.success === 1); }); });