Ghost/ghost/job-manager/test/is-cron-expression.test.js
Naz 3da365999d Added cron expression validation
no issue

- CRON format is the most common one used for job scheduling and is well known to most developers
- This will become one of supported formats for job scheduling
2020-11-05 17:07:27 +13:00

20 lines
766 B
JavaScript

// Switch these lines once there are useful utils
// const testUtils = require('./utils');
require('./utils');
const isCronExpression = new require('../lib/is-cron-expression');
describe('Is cron expression', function () {
it('valid cron expressions', function () {
should(isCronExpression('* * * * *')).be.true();
should(isCronExpression('1 * * * *')).be.true();
should(isCronExpression('* * 12-15 * * *'), 'Range should be 0-23').be.true();
});
it('invalid cron expressions', function () {
should(isCronExpression('123 * * * *')).not.be.true();
should(isCronExpression('a * * * *')).not.be.true();
should(isCronExpression('* * 12-36 * * *'), 'Invalid range should be 0-23').not.be.true();
});
});