AnonSec Shell
Server IP : 162.213.251.212  /  Your IP : 18.191.62.85   [ Reverse IP ]
Web Server : LiteSpeed
System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : allssztx ( 535)
PHP Version : 8.1.31
Disable Function : NONE
Domains : 1 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/allssztx/needapair.com/node_modules/node-cron/test/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /home/allssztx/needapair.com/node_modules/node-cron/test/task-test.js
const { assert } = require('chai');
const sinon = require('sinon');
const Task = require('../src/task');

describe('Task', () => {
    beforeEach(() => {
        this.clock = sinon.useFakeTimers(new Date(2018, 0, 1, 0, 0, 0, 0));
    });

    afterEach(() => {
        this.clock.restore();
    });

    it('should emit event on finish a task', async () => {
        let finished = false;
        let task = new Task(() => 'ok');
        task.on('task-finished', () => finished = true);
        await task.execute();
        assert.equal(true, finished);
    });

    it('should emit event on error a task', async () => {
        let error;
        let task = new Task(() => {
            throw Error('execution error');
        });
        task.on('task-failed', (err) => error = err.message);
        await task.execute();
        assert.equal('execution error', error);
    });

    it('should emit event on finish a promise task', async () => {
        let finished = false;
        const promise = () => new Promise((resolve) => resolve('ok'));
        let task = new Task(promise);
        task.on('task-finished', () => finished = true);
        await task.execute();
        assert.equal(true, finished);
    });

    it('should emit event on error a promise task', async () => {
        let failed = false;
        const promise = () => new Promise((resolve, reject) => reject('errou'));
        const task = new Task(promise);
        task.on('task-failed', (error) => failed = error);
        await task.execute();
        assert.equal('errou', failed);
    });
});

Anon7 - 2022
AnonSec Team