Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

validate-week-day-test.js 1.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use strict';
  2. const { expect } = require('chai');
  3. const validate = require('../../src/pattern-validation');
  4. describe('pattern-validation.js', () => {
  5. describe('validate week day', () => {
  6. it('should fail with invalid week day', () => {
  7. expect(() => {
  8. validate('* * * * 9');
  9. }).to.throw('9 is a invalid expression for week day');
  10. });
  11. it('should fail with invalid week day name', () => {
  12. expect(() => {
  13. validate('* * * * foo');
  14. }).to.throw('foo is a invalid expression for week day');
  15. });
  16. it('should not fail with valid week day', () => {
  17. expect(() => {
  18. validate('* * * * 5');
  19. }).to.not.throw();
  20. });
  21. it('should not fail with valid week day name', () => {
  22. expect(() => {
  23. validate('* * * * Friday');
  24. }).to.not.throw();
  25. });
  26. it('should not fail with * for week day', () => {
  27. expect(() => {
  28. validate('* * * * *');
  29. }).to.not.throw();
  30. });
  31. it('should not fail with */2 for week day', () => {
  32. expect(() => {
  33. validate('* * * */2 *');
  34. }).to.not.throw();
  35. });
  36. it('should not fail with Monday-Sunday for week day', () => {
  37. expect(() => {
  38. validate('* * * * Monday-Sunday');
  39. }).to.not.throw();
  40. });
  41. it('should not fail with 1-7 for week day', () => {
  42. expect(() => {
  43. validate('0 0 1 1 1-7');
  44. }).to.not.throw();
  45. });
  46. });
  47. });