helper.test.js 1.1 KB

123456789101112131415161718192021222324252627282930
  1. 'use strict';
  2. /**
  3. * 辅助方法扩展 单元测试
  4. *
  5. * @author Mai
  6. * @data 2018/4/20
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. describe('test/app/extend/helper.test.js', () => {
  11. it('ValidTemplateCode test', function () {
  12. const ctx = app.mockContext();
  13. assert(ctx.helper.ValidTemplateCode('z') === true);
  14. assert(ctx.helper.ValidTemplateCode('Z') === true);
  15. assert(ctx.helper.ValidTemplateCode('-') === false);
  16. assert(ctx.helper.ValidTemplateCode('1') === false);
  17. assert(ctx.helper.ValidTemplateCode('z1') === true);
  18. assert(ctx.helper.ValidTemplateCode('z1-') === false);
  19. assert(ctx.helper.ValidTemplateCode('zav') === true);
  20. assert(ctx.helper.ValidTemplateCode('z1-e') === true);
  21. assert(ctx.helper.ValidTemplateCode('z1-e-1') === true);
  22. });
  23. it('ValidTemplateIndexCode test', function () {
  24. const ctx = app.mockContext();
  25. assert(ctx.helper.ValidTemplateIndexCode('z2-d-d-1~z2-d-d-5 高填方路段处理 同z2-d-c-1~z2-d-c-5') === false);
  26. });
  27. });