| 
									
										
										
										
											2018-08-27 23:04:15 +02:00
										 |  |  | import { expect, tap } from '@pushrocks/tapbundle'; | 
					
						
							|  |  |  | import * as smarthbs from '../ts/index'; | 
					
						
							|  |  |  | import * as path from 'path'; | 
					
						
							| 
									
										
										
										
											2017-02-19 04:12:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-27 23:04:15 +02:00
										 |  |  | let testHbsDir = path.join(__dirname, 'hbs_testfiles'); | 
					
						
							|  |  |  | let testPartialDir = path.join(testHbsDir, 'partials'); | 
					
						
							|  |  |  | let testResultDir = path.join(__dirname, 'testresult'); | 
					
						
							| 
									
										
										
										
											2017-05-10 16:55:25 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-01 16:57:53 +02:00
										 |  |  | tap.test('smarthbs -> should create partials', async () => { | 
					
						
							| 
									
										
										
										
											2018-08-27 23:04:15 +02:00
										 |  |  |   await smarthbs.registerPartialDir(testPartialDir); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2017-02-19 04:12:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-01 16:57:53 +02:00
										 |  |  | tap.test('smarthbs -> should compile a directory', async () => { | 
					
						
							| 
									
										
										
										
											2018-08-27 23:04:15 +02:00
										 |  |  |   smarthbs.compileDirectory(testHbsDir, testResultDir, 'data.json'); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2017-02-19 04:12:17 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-01 16:57:53 +02:00
										 |  |  | tap.test('', async () => { | 
					
						
							| 
									
										
										
										
											2018-08-27 23:04:15 +02:00
										 |  |  |   let templateString = '{{{firstVar}}} {{secondVar}}'; | 
					
						
							|  |  |  |   let templateVars = await smarthbs.findVarsInHbsString(templateString); | 
					
						
							|  |  |  |   expect(templateVars).to.include('firstVar'); | 
					
						
							|  |  |  |   expect(templateVars).to.include('secondVar'); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2017-05-01 16:57:53 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | tap.test('', async () => { | 
					
						
							| 
									
										
										
										
											2018-08-27 23:04:15 +02:00
										 |  |  |   let templateString = | 
					
						
							|  |  |  |     '{{{firstVar}}} {{secondVar}} {{thirdVar}} {{fourthVar}} {{fourthVar.someKey}} {{fourthVar.otherKey.nextKey}}'; | 
					
						
							| 
									
										
										
										
											2017-05-01 16:57:53 +02:00
										 |  |  |   let missingVars = await smarthbs.checkVarsSatisfaction(templateString, { | 
					
						
							|  |  |  |     firstVar: 'hi', | 
					
						
							|  |  |  |     secondVar: 'hello', | 
					
						
							|  |  |  |     fourthVar: { | 
					
						
							|  |  |  |       otherKey: { | 
					
						
							|  |  |  |         nextKey: 'wow' | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-08-27 23:04:15 +02:00
										 |  |  |   }); | 
					
						
							|  |  |  |   expect(missingVars).to.contain('thirdVar', 'fourthVar.someKey'); | 
					
						
							|  |  |  |   expect(missingVars).to.not.contain('secondVar', 'fourthVar.otherKey.nextKey'); | 
					
						
							|  |  |  | }); | 
					
						
							| 
									
										
										
										
											2017-05-01 16:57:53 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-27 23:04:15 +02:00
										 |  |  | tap.start(); |