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);
|
|
|
|
});
|
|
|
|
|
2019-06-17 14:54:39 +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;
|
|
|
|
testCronManager.addCronjob('* * * * * *', () => {
|
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();
|