mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-20 06:29:32 +02:00
feat: add Crontab Guru tool for parsing and validating crontab expressions
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { expect, describe, it } from 'vitest';
|
||||
import { validateCrontab, explainCrontab } from './service';
|
||||
|
||||
describe('crontab-guru service', () => {
|
||||
it('validates correct crontab expressions', () => {
|
||||
expect(validateCrontab('35 16 * * 0-5')).toBe(true);
|
||||
expect(validateCrontab('* * * * *')).toBe(true);
|
||||
expect(validateCrontab('0 12 1 * *')).toBe(true);
|
||||
});
|
||||
|
||||
it('invalidates incorrect crontab expressions', () => {
|
||||
expect(validateCrontab('invalid expression')).toBe(false);
|
||||
expect(validateCrontab('61 24 * * *')).toBe(false);
|
||||
});
|
||||
|
||||
it('explains valid crontab expressions', () => {
|
||||
expect(explainCrontab('35 16 * * 0-5')).toMatch(/At 04:35 PM/);
|
||||
expect(explainCrontab('* * * * *')).toMatch(/Every minute/);
|
||||
});
|
||||
|
||||
it('returns error for invalid crontab explanation', () => {
|
||||
expect(explainCrontab('invalid expression')).toMatch(
|
||||
/Invalid crontab expression/
|
||||
);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user