| 
									
										
										
										
											2019-04-10 11:34:30 +02: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 14:06:20 +02: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 14:06:20 +02:00
										 |  |  |   const done = tools.defer(); | 
					
						
							|  |  |  |   let counter = 0; | 
					
						
							| 
									
										
										
										
											2020-05-27 16:59:26 +00:00
										 |  |  |   testCronManager.addCronjob('*/2 * * * * *', () => { | 
					
						
							| 
									
										
										
										
											2019-06-17 16:54:39 +02:00
										 |  |  |     if (counter === 10) { | 
					
						
							| 
									
										
										
										
											2019-04-10 14:06:20 +02:00
										 |  |  |       done.resolve(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2019-06-17 16:54:39 +02:00
										 |  |  |     counter++; | 
					
						
							| 
									
										
										
										
											2019-04-10 14:06:20 +02:00
										 |  |  |     console.log(`hey ${counter}`); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  |   testCronManager.start(); | 
					
						
							|  |  |  |   await done.promise; | 
					
						
							|  |  |  |   testCronManager.stop(); | 
					
						
							| 
									
										
										
										
											2019-04-10 11:34:30 +02:00
										 |  |  | }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tap.start(); |