UNPKG

@juzi/wechaty-puppet-whatsapp

Version:
45 lines 1.92 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const schedule_manager_js_1 = __importDefault(require("./schedule-manager.js")); const tstest_1 = require("tstest"); const node_schedule_1 = require("node-schedule"); (0, tstest_1.test)('scheduleManager task add and remove test', async (t) => { try { const scheduleManager = schedule_manager_js_1.default.Instance; t.ok(scheduleManager instanceof schedule_manager_js_1.default); const task = scheduleManager.addScheduledTask('42 * * * *', () => { console.info('The answer to life, the universe, and everything!'); }); t.ok(task instanceof node_schedule_1.Job); scheduleManager.removeScheduledTask(task); // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition t.ok(task.nextInvocation() === null); scheduleManager.clearAllTasks(); t.pass('scheduleManager add and remove test pass.'); } catch (e) { t.fail(e); } }); (0, tstest_1.test)('scheduleManager task add and clear test', async (t) => { try { const scheduleManager = schedule_manager_js_1.default.Instance; t.ok(scheduleManager instanceof schedule_manager_js_1.default); const task = scheduleManager.addScheduledTask('42 * * * *', () => { console.info('The answer to life, the universe, and everything!'); }); t.ok(task instanceof node_schedule_1.Job); scheduleManager.clearAllTasks(); // @ts-ignore const taskCount = scheduleManager.jobPool.length; t.ok(taskCount === 0); t.pass('scheduleManager add and clear test pass.'); } catch (e) { t.fail(e); } }); //# sourceMappingURL=schedule-manager.spec.js.map