34 lines
891 B
JavaScript
34 lines
891 B
JavaScript
import {join, dirname} from "node:path";
|
|
|
|
import test from "ava";
|
|
import { rollup } from "rollup";
|
|
|
|
import { getCode } from "../util/test.js";
|
|
|
|
import html from "../../src/index.ts";
|
|
import handlebars from "handlebars";
|
|
|
|
const output = { dir: 'output', format: 'es' };
|
|
|
|
import {readFile} from "node:fs/promises";
|
|
import {fileURLToPath} from "node:url";
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
process.chdir(join(__dirname, 'fixtures'));
|
|
|
|
test.serial('handlebars', async (t) => {
|
|
const template = await readFile('index.hbs', {encoding: "utf-8"});
|
|
const bundle = await rollup({
|
|
input: 'index.hbs',
|
|
plugins: [
|
|
html({
|
|
// Should we define an output template here?!
|
|
transform(ctx){
|
|
return handlebars.compile(template)({a:'a'})
|
|
}
|
|
})
|
|
]
|
|
});
|
|
const code = await getCode(bundle, output, true);
|
|
t.snapshot(code);
|
|
});
|