captcha.test.js 637 B

12345678910111213141516171819202122232425262728
  1. /**
  2. * geetest验证码单元测试
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/10/19
  6. * @version
  7. */
  8. 'use strict';
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. const Captcha = require('../../../app/lib/captcha');
  11. describe('test/app/lib/captcha.test.js', () => {
  12. it('captcha register', function* () {
  13. // 创建 ctx
  14. const ctx = app.mockContext({
  15. session: {},
  16. });
  17. const captcha = new Captcha(app);
  18. const response = yield captcha.register(ctx);
  19. assert(response !== '');
  20. assert(typeof response === 'object');
  21. assert(response.success === 1);
  22. });
  23. });