!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/kiosk/node_modules/node-cron/test/   drwxr-xr-x
Free 13.22 GB of 57.97 GB (22.8%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     node-cron-test.js (4.43 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
const { assert } = require('chai');
const sinon = require('sinon');
const cron = require('../src/node-cron');

describe('node-cron', () => {
    beforeEach(() => {
        this.clock = sinon.useFakeTimers(new Date(2018, 0, 1, 0, 0, 0, 0));
    });
    
    afterEach(() => {
        this.clock.restore();
    });
    
    describe('schedule', () => {
        it('should schedule a task', () => {
            let executed = 0;
            cron.schedule('* * * * * *', () => {
                executed += 1;
            });
            
            this.clock.tick(2000);
            
            assert.equal(2, executed);
        });
        
        it('should schedule a task with America/Sao_Paulo timezone', (done) => {
            let startDate = new Date('Thu, 20 Sep 2018 00:00:00.000Z');
            this.clock.restore();
            this.clock = sinon.useFakeTimers(startDate);
            cron.schedule('* * * * * *', (date) => {
                assert.equal(19, date.getDate());
                assert.equal(8, date.getMonth());
                assert.equal(2018, date.getFullYear());
                assert.equal(21, date.getHours());
                assert.equal(0, date.getMinutes());
                assert.equal(1, date.getSeconds());
                done();
            }, {
                timezone: 'America/Sao_Paulo'
            });
            this.clock.tick(1000);
        });
        
        it('should schedule a task with Europe/Rome timezone', (done) => {
            let startDate = new Date('Thu, 20 Sep 2018 00:00:00.000Z');
            this.clock.restore();
            this.clock = sinon.useFakeTimers(startDate);
            cron.schedule('* * * * * *', (date) => {
                assert.equal(20, date.getDate());
                assert.equal(8, date.getMonth());
                assert.equal(2018, date.getFullYear());
                assert.equal(2, date.getHours());
                assert.equal(0, date.getMinutes());
                assert.equal(1, date.getSeconds());
                done();
            }, {
                timezone: 'Europe/Rome'
            });
            this.clock.tick(1000);
        });
        
        it('should schedule a task stoped', () => {
            let executed = 0;
            cron.schedule('* * * * * *', () => {
                executed += 1;
            }, { scheduled: false });
            
            this.clock.tick(2000);
            
            assert.equal(0, executed);
        });
        
        it('should start a stoped task', () => {
            let executed = 0;
            let scheduledTask = cron.schedule('* * * * * *', () => {
                executed += 1;
            }, { scheduled: false });
            
            this.clock.tick(2000);
            assert.equal(0, executed);
            scheduledTask.start();
            this.clock.tick(2000);
            assert.equal(2, executed);
        });
        
        it('should recover missed executions', (done) => {
            let executed = 0;
            this.clock.restore();
            let scheduledTask = cron.schedule('* * * * * *', () => {
                executed += 1;
            }, { recoverMissedExecutions: true });
            
            let wait = true;
            let startedAt = new Date();
            
            while(wait){
                if((new Date().getTime() - startedAt.getTime()) > 1000){
                    wait = false;
                }
            }
            
            setTimeout(() => {
                scheduledTask.stop();
                assert.equal(2, executed);
                done();
            }, 1000);
        }).timeout(4000);

        it('should schedule a background task', () => {
            let task = cron.schedule('* * * * * *', './test/assets/dummy-task.js');
            assert.isNotNull(task);
            assert.isDefined(task);
            assert.isTrue(task.isRunning());
            task.stop();
        });
    });
    
    describe('validate', () => {
        it('should validate a pattern', () => {
            assert.isTrue(cron.validate('* * * * * *')); 
        });
        
        it('should fail with a invalid pattern', () => {
            assert.isFalse(cron.validate('62 * * * * *')); 
        });
    });

    describe('getTasks', () => {
        beforeEach(() => {
            global.scheduledTasks = new Map();
        });

        it('should store a task', () => {
            cron.schedule('* * * * *', () => {});
            assert.lengthOf(cron.getTasks(), 1);
        });
    });
});

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0047 ]--