2025-10-28 06:27:29 +00:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import { tap, expect } from '@git.zone/tstest/tapbundle';
							 | 
						
					
						
							
								
									
										
										
										
											2023-07-12 15:09:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import * as smartrx from '@push.rocks/smartrx';
							 | 
						
					
						
							
								
									
										
										
										
											2016-06-10 02:27:04 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-03 17:00:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import * as smartcli from '../ts/index.js';
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-22 21:03:28 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								tap.test('should create a new Smartcli', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-03 18:47:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const smartCliTestObject = new smartcli.Smartcli();
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-03 17:00:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  expect(smartCliTestObject).toBeInstanceOf(smartcli.Smartcli);
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-03 12:10:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-22 21:03:28 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-03 18:47:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								tap.test('should add an command', async (toolsArg) => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const done = toolsArg.defer();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  const smartCliTestObject = new smartcli.Smartcli();
							 | 
						
					
						
							
								
									
										
										
										
											2023-07-12 15:09:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const awesomeCommandSubject = smartCliTestObject.addCommand('awesome');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  expect(awesomeCommandSubject).toBeInstanceOf(smartrx.rxjs.Subject);
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-03 18:47:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  awesomeCommandSubject.subscribe(() => {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    done.resolve();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  console.log(process.argv);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  process.argv.splice(2, 0, 'awesome');
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  console.log(process.argv);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  smartCliTestObject.startParse();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  await done.promise;
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-03 12:10:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-22 21:03:28 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								tap.test('should start parsing a standardTask', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-03 18:47:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const smartCliTestObject = new smartcli.Smartcli();
							 | 
						
					
						
							
								
									
										
										
										
											2023-07-12 15:09:53 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  expect(smartCliTestObject.standardCommand()).toBeInstanceOf(smartrx.rxjs.Subject);
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-03 12:10:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-22 21:03:28 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-03 12:10:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								let hasExecuted: boolean = false;
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-22 23:16:49 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-22 21:03:28 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								tap.test('should accept a command', async () => {
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-03 18:47:35 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  const smartCliTestObject = new smartcli.Smartcli();
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-03 17:00:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  smartCliTestObject.addCommand('triggerme').subscribe(() => {
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-03 12:10:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								    hasExecuted = true;
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							
								
									
										
										
										
											2022-08-03 17:00:36 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								  smartCliTestObject.triggerCommand('triggerme', {});
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  expect(hasExecuted).toBeTrue();
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-03 12:10:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								});
							 | 
						
					
						
							
								
									
										
										
										
											2017-04-22 21:03:28 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2018-05-03 12:10:39 +02:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								tap.start();
							 |