41 lines
1.0 KiB
JavaScript

import {join, dirname} from "node:path";
import {test, expect} from "@jest/globals";
import { rollup } from "rollup";
import {debugPrintOutput, getCode, serializer} from "../util/index.ts";
import html from "../../src/index.ts";
import handlebars from "handlebars";
import {fileURLToPath} from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
process.chdir(join(__dirname, 'fixtures'));
test('handlebars', async () => {
expect.addSnapshotSerializer(serializer);
const bundle = await rollup({
input: 'index.hbs',
plugins: [
html({
include: [
'**/*.(html|hbs)',// html or handlebars
],
transform(src){
return handlebars.compile(src)({a:'a'})
}
})
]
});
const code = await getCode(bundle);
debugPrintOutput('handlebars',code);
expect({code}).toMatchSnapshot();
});
// TODO various parameters
// - format: cjs, iifi, ...
// - sourcemap: inline, false, (and the various exotic sourcemap options)
// Watch mode tests would be its own dir
// ...