smarttime/test/test.cronmanager.ts

28 lines
701 B
TypeScript
Raw Normal View History

2019-04-10 09:34:30 +00:00
import { tap, expect } from '@pushrocks/tapbundle';
import * as smarttime from '../ts/index';
let testCronManager: smarttime.CronManager;
tap.test('should create a valid instance of cronmanager', async () => {
testCronManager = new smarttime.CronManager();
2019-04-10 12:06:20 +00:00
expect(testCronManager).to.be.instanceOf(smarttime.CronManager);
});
2020-07-11 21:41:33 +00:00
tap.test('should create a valid cronJon', async (tools) => {
2019-04-10 12:06:20 +00:00
const done = tools.defer();
let counter = 0;
2020-05-27 16:59:26 +00:00
testCronManager.addCronjob('*/2 * * * * *', () => {
2019-06-17 14:54:39 +00:00
if (counter === 10) {
2019-04-10 12:06:20 +00:00
done.resolve();
}
2019-06-17 14:54:39 +00:00
counter++;
2019-04-10 12:06:20 +00:00
console.log(`hey ${counter}`);
});
testCronManager.start();
await done.promise;
testCronManager.stop();
2019-04-10 09:34:30 +00:00
});
tap.start();