fix(core): update

This commit is contained in:
2022-07-24 15:30:19 +02:00
parent 97400fa501
commit b382256cc7
21 changed files with 13690 additions and 1078 deletions

View File

@ -1,10 +1,14 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smarthbs from '../ts/index';
import * as smarthbs from '../ts/index.js';
import * as smartpath from '@pushrocks/smartpath';
import * as path from 'path';
let testHbsDir = path.join(__dirname, 'hbs_testfiles');
const dirname = smartpath.get.dirnameFromImportMetaUrl(import.meta.url);
let testHbsDir = path.join(dirname, 'hbs_testfiles');
let testPartialDir = path.join(testHbsDir, 'partials');
let testResultDir = path.join(__dirname, 'testresult');
let testResultDir = path.join(dirname, 'testresult');
tap.test('smarthbs -> should create partials', async () => {
await smarthbs.registerPartialDir(testPartialDir);
@ -17,8 +21,8 @@ tap.test('smarthbs -> should compile a directory', async () => {
tap.test('', async () => {
let templateString = '{{{firstVar}}} {{secondVar}}';
let templateVars = await smarthbs.findVarsInHbsString(templateString);
expect(templateVars).to.include('firstVar');
expect(templateVars).to.include('secondVar');
expect(templateVars).toContain('firstVar');
expect(templateVars).toContain('secondVar');
});
tap.test('', async () => {
@ -29,12 +33,14 @@ tap.test('', async () => {
secondVar: 'hello',
fourthVar: {
otherKey: {
nextKey: 'wow'
}
}
nextKey: 'wow',
},
},
});
expect(missingVars).to.contain('thirdVar', 'fourthVar.someKey');
expect(missingVars).to.not.contain('secondVar', 'fourthVar.otherKey.nextKey');
expect(missingVars).toContain('thirdVar');
expect(missingVars).toContain('fourthVar.someKey');
expect(missingVars).not.toContain('secondVar');
expect(missingVars).not.toContain('fourthVar.otherKey.nextKey');
});
tap.start();