您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

validate-hours-test.js 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. const { expect } = require('chai');
  3. const validate = require('../../src/pattern-validation');
  4. describe('pattern-validation.js', () => {
  5. describe('validate hour', () => {
  6. it('should fail with invalid hour', () => {
  7. expect(() => {
  8. validate('* 25 * * *');
  9. }).to.throw('25 is a invalid expression for hour');
  10. });
  11. it('should not fail with valid hour', () => {
  12. expect(() => {
  13. validate('* 12 * * *');
  14. }).to.not.throw();
  15. });
  16. it('should not fail with * for hour', () => {
  17. expect(() => {
  18. validate('* * * * * *');
  19. }).to.not.throw();
  20. });
  21. it('should not fail with */2 for hour', () => {
  22. expect(() => {
  23. validate('* */2 * * *');
  24. }).to.not.throw();
  25. });
  26. it('should accept range for hours', () => {
  27. expect(() => {
  28. validate('* 3-20 * * *');
  29. }).to.not.throw();
  30. });
  31. });
  32. });