fix(core): update
This commit is contained in:
26
test/test.ts
26
test/test.ts
@ -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();
|
||||
|
Reference in New Issue
Block a user