step 1 : setting konfigurasi

This commit is contained in:
sindhu
2024-07-25 09:45:02 +07:00
parent 9f972502d3
commit 84607a40db
1642 changed files with 1427528 additions and 0 deletions

91
node_modules/node-cron/test/scheduler-test.js generated vendored Normal file
View File

@@ -0,0 +1,91 @@
const { assert } = require('chai');
const sinon = require('sinon');
const Scheduler = require('../src/scheduler');
describe('Scheduler', () => {
beforeEach(() => {
this.clock = sinon.useFakeTimers();
});
afterEach(() => {
this.clock.restore();
});
it('should emit an event on matched time', (done) => {
let scheduler = new Scheduler('* * * * * *');
scheduler.on('scheduled-time-matched', (date) => {
assert.isNotNull(date);
assert.instanceOf(date, Date);
scheduler.stop();
done();
});
scheduler.start();
this.clock.tick(1000);
});
it('should emit an event every second', (done) => {
let scheduler = new Scheduler('* * * * * *');
let emited = 0;
scheduler.on('scheduled-time-matched', (date) => {
emited += 1;
assert.isNotNull(date);
assert.instanceOf(date, Date);
if(emited === 5){
scheduler.stop();
done();
}
});
scheduler.start();
this.clock.tick(5000);
});
it('should recover missed executions', (done) => {
this.clock.restore();
let scheduler = new Scheduler('* * * * * *', null, true);
let emited = 0;
scheduler.on('scheduled-time-matched', () => {
emited += 1;
});
scheduler.start();
let wait = true;
let startedAt = new Date();
while(wait){
if((new Date().getTime() - startedAt.getTime()) > 1000){
wait = false;
}
}
setTimeout(() => {
scheduler.stop();
assert.equal(2, emited);
done();
}, 1000);
}).timeout(3000);
it('should ignore missed executions', (done) => {
this.clock.restore();
let scheduler = new Scheduler('* * * * * *', null, false);
let emited = 0;
scheduler.on('scheduled-time-matched', () => {
emited += 1;
});
scheduler.start();
let wait = true;
let startedAt = new Date();
while(wait){
if((new Date().getTime() - startedAt.getTime()) > 1000){
wait = false;
}
}
setTimeout(() => {
scheduler.stop();
assert.equal(1, emited);
done();
}, 1000);
}).timeout(3000);
});