37 lines
920 B
JavaScript

import {join, dirname} from "node:path";
import {test, expect} from "@jest/globals";
import { rollup } from "rollup";
import {debugPrintOutput, getCode} 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 () => {
const bundle = await rollup({
input: 'index.hbs',
plugins: [
html({
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
// ...