Initial import from local backup (Documents-Playground/pakerpale)

This commit is contained in:
jeonghwa
2026-07-03 05:27:29 +09:00
commit d918e2eddc
2971 changed files with 264195 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
'use strict';
var expect = require('expect.js');
var validate = require('../../src/pattern-validation');
describe('pattern-validation.js', () => {
describe('validate day of month', () => {
it('should fail with invalid day of month', () => {
expect(() => {
validate('* * 32 * *');
}).to.throwException((e) =>{
expect('32 is a invalid expression for day of month').to.equal(e);
});
});
it('should not fail with valid day of month', () => {
expect(() => {
validate('0 * * 15 * *');
}).to.not.throwException();
});
it('should not fail with * for day of month', () => {
expect(() => {
validate('* * * * * *');
}).to.not.throwException();
});
it('should not fail with */2 for day of month', () => {
expect(() => {
validate('* * */2 * *');
}).to.not.throwException();
});
});
});

View File

@@ -0,0 +1,40 @@
'use strict';
var expect = require('expect.js');
var validate = require('../../src/pattern-validation');
describe('pattern-validation.js', () => {
describe('validate hour', () => {
it('should fail with invalid hour', () => {
expect(() => {
validate('* 25 * * *');
}).to.throwException((e) => {
expect('25 is a invalid expression for hour').to.equal(e);
});
});
it('should not fail with valid hour', () => {
expect(() => {
validate('* 12 * * *');
}).to.not.throwException();
});
it('should not fail with * for hour', () => {
expect(() => {
validate('* * * * * *');
}).to.not.throwException();
});
it('should not fail with */2 for hour', () => {
expect(() => {
validate('* */2 * * *');
}).to.not.throwException();
});
it('should accept range for hours', () => {
expect(() => {
validate('* 3-20 * * *');
}).to.not.throwException();
});
});
});

View File

@@ -0,0 +1,34 @@
'use strict';
var expect = require('expect.js');
var validate = require('../../src/pattern-validation');
describe('pattern-validation.js', () => {
describe('validate minutes', () => {
it('should fail with invalid minute', () => {
expect(() => {
validate('63 * * * *');
}).to.throwException((e) => {
expect('63 is a invalid expression for minute').to.equal(e);
});
});
it('should not fail with valid minute', () => {
expect(() => {
validate('30 * * * *');
}).to.not.throwException();
});
it('should not fail with *', () => {
expect(() => {
validate('* * * * *');
}).to.not.throwException();
});
it('should not fail with */2', () => {
expect(() => {
validate('*/2 * * * *');
}).to.not.throwException();
});
});
});

View File

@@ -0,0 +1,48 @@
'use strict';
var expect = require('expect.js');
var validate = require('../../src/pattern-validation');
describe('pattern-validation.js', () => {
describe('validate month', () => {
it('should fail with invalid month', () => {
expect( () => {
validate('* * * 13 *');
}).to.throwException((e) => {
expect('13 is a invalid expression for month').to.equal(e);
});
});
it('should fail with invalid month name', () => {
expect( () => {
validate('* * * foo *');
}).to.throwException(function(e){
expect('foo is a invalid expression for month').to.equal(e);
});
});
it('should not fail with valid month', () => {
expect( () => {
validate('* * * 10 *');
}).to.not.throwException();
});
it('should not fail with valid month name', () => {
expect( () => {
validate('* * * September *');
}).to.not.throwException();
});
it('should not fail with * for month', () => {
expect( () => {
validate('* * * * *');
}).to.not.throwException();
});
it('should not fail with */2 for month', () => {
expect( () => {
validate('* * * */2 *');
}).to.not.throwException();
});
});
});

View File

@@ -0,0 +1,21 @@
'use strict';
var expect = require('expect.js');
var Task = require('../../src/task');
describe('Task', () => {
it('should accept string for pattern', () => {
expect(() => {
new Task('* * * * *');
}).to.not.throwException();
});
it('should fail with a non string value for pattern', () => {
expect(() => {
new Task([]);
}).to.throwException((e) => {
expect('pattern must be a string!').to.equal(e);
});
});
});

View File

@@ -0,0 +1,34 @@
'use strict';
var expect = require('expect.js');
var validate = require('../../src/pattern-validation');
describe('pattern-validation.js', () => {
describe('validate seconds', () => {
it('should fail with invalid second', () => {
expect(() => {
validate('63 * * * * *');
}).to.throwException((e) => {
expect('63 is a invalid expression for second').to.equal(e);
});
});
it('should not fail with valid second', () => {
expect(() => {
validate('30 * * * * *');
}).to.not.throwException();
});
it('should not fail with * for second', () => {
expect(() => {
validate('* * * * * *');
}).to.not.throwException();
});
it('should not fail with */2 for second', () => {
expect(() => {
validate('*/2 * * * * *');
}).to.not.throwException();
});
});
});

View File

@@ -0,0 +1,16 @@
'use strict';
var expect = require('expect.js');
var cron = require('../../src/node-cron');
describe('public .validate() method', () => {
it('should succeed with a valid expression', () => {
var result = cron.validate('59 * * * *');
expect(result).to.equal(true);
});
it('should fail with an invalid expression', () => {
var result = cron.validate('60 * * * *');
expect(result).to.equal(false);
});
});

View File

@@ -0,0 +1,60 @@
'use strict';
var expect = require('expect.js');
var validate = require('../../src/pattern-validation');
describe('pattern-validation.js', () => {
describe('validate week day', () => {
it('should fail with invalid week day', () => {
expect(() => {
validate('* * * * 9');
}).to.throwException((e) => {
expect('9 is a invalid expression for week day').to.equal(e);
});
});
it('should fail with invalid week day name', () => {
expect(() => {
validate('* * * * foo');
}).to.throwException((e) => {
expect('foo is a invalid expression for week day').to.equal(e);
});
});
it('should not fail with valid week day', () => {
expect(() => {
validate('* * * * 5');
}).to.not.throwException();
});
it('should not fail with valid week day name', () => {
expect(() => {
validate('* * * * Friday');
}).to.not.throwException();
});
it('should not fail with * for week day', () => {
expect(() => {
validate('* * * * *');
}).to.not.throwException();
});
it('should not fail with */2 for week day', () => {
expect(() => {
validate('* * * */2 *');
}).to.not.throwException();
});
it('should not fail with Monday-Sunday for week day', () => {
expect(() => {
validate('* * * * Monday-Sunday');
}).to.not.throwException();
});
it('should not fail with 1-7 for week day', () => {
expect(() => {
validate('0 0 1 1 1-7');
}).to.not.throwException();
});
});
});