First private release. Check updated README.md for details
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
2
test/templating/fixtures/batman.js
Normal file
2
test/templating/fixtures/batman.js
Normal file
@@ -0,0 +1,2 @@
|
||||
export const b = ()=>'batman';
|
||||
console.log(b());
|
||||
3
test/templating/fixtures/icon.svg
Normal file
3
test/templating/fixtures/icon.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
|
||||
<path style="fill:none;stroke:#00ff0d;stroke-width:5;stroke-linecap:square;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1" d="M4.1 14.72 16 26.31 28.38 5.09"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 244 B |
8
test/templating/fixtures/index.hbs
Normal file
8
test/templating/fixtures/index.hbs
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta data-test="{{a}}"/>
|
||||
</head>
|
||||
<body>
|
||||
<script src="./batman.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
8
test/templating/fixtures/index.html
Normal file
8
test/templating/fixtures/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<link rel="icon" href="./icon.svg">
|
||||
</head>
|
||||
<body>
|
||||
<script src="./batman.js" type="module"></script>
|
||||
</body>
|
||||
</html>
|
||||
1
test/templating/fixtures/joker.css
Normal file
1
test/templating/fixtures/joker.css
Normal file
@@ -0,0 +1 @@
|
||||
* { width: 100%; }
|
||||
55
test/templating/snapshots/test.js.md
Normal file
55
test/templating/snapshots/test.js.md
Normal file
@@ -0,0 +1,55 @@
|
||||
# Snapshot report for `test/templating/test.js`
|
||||
|
||||
The actual snapshot is saved in `test.js.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## handlebars
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
code: `const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
␊
|
||||
export { b };␊
|
||||
//# sourceMappingURL=batman-c7fa228c.js.map␊
|
||||
`,
|
||||
fileName: 'batman-c7fa228c.js',
|
||||
map: SourceMap {
|
||||
file: 'batman-c7fa228c.js',
|
||||
mappings: 'AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;',
|
||||
names: [],
|
||||
sources: [
|
||||
'../batman.js',
|
||||
],
|
||||
sourcesContent: [
|
||||
`export const b = ()=>'batman';␊
|
||||
console.log(b());␊
|
||||
`,
|
||||
],
|
||||
version: 3,
|
||||
},
|
||||
source: undefined,
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'batman-c7fa228c.js.map',
|
||||
map: undefined,
|
||||
source: '{"version":3,"file":"batman-c7fa228c.js","sources":["../batman.js"],"sourcesContent":["export const b = ()=>\'batman\';\\nconsole.log(b());\\n"],"names":[],"mappings":"AAAY,MAAC,CAAC,GAAG,IAAI,SAAS;AAC9B,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;;;;"}',
|
||||
},
|
||||
{
|
||||
code: undefined,
|
||||
fileName: 'index.html',
|
||||
map: undefined,
|
||||
source: `<html><head>␊
|
||||
<meta data-test="a">␊
|
||||
</head>␊
|
||||
<body>␊
|
||||
<script src="batman-c7fa228c.js" type="module"></script>␊
|
||||
␊
|
||||
␊
|
||||
</body></html>`,
|
||||
},
|
||||
]
|
||||
BIN
test/templating/snapshots/test.js.snap
Normal file
BIN
test/templating/snapshots/test.js.snap
Normal file
Binary file not shown.
43
test/templating/test.js
Normal file
43
test/templating/test.js
Normal file
@@ -0,0 +1,43 @@
|
||||
import {join, dirname} from "node:path";
|
||||
|
||||
import test from "ava";
|
||||
import { rollup } from "rollup";
|
||||
|
||||
import {debugPrintOutput, getCode} from "../util/test.js";
|
||||
|
||||
import html from "../../src/index.ts";
|
||||
import handlebars from "handlebars";
|
||||
|
||||
const output = {
|
||||
dir: 'output', // Output all files
|
||||
format: 'es', // iifi and cjs should be added to tests
|
||||
sourcemap: true,// Test if #sourcemapUrl is not accidentally included in the html-output
|
||||
};
|
||||
|
||||
import {fileURLToPath} from "node:url";
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
process.chdir(join(__dirname, 'fixtures'));
|
||||
|
||||
|
||||
test.serial('handlebars', async (t) => {
|
||||
const bundle = await rollup({
|
||||
input: 'index.hbs',
|
||||
plugins: [
|
||||
html({
|
||||
transform(src){
|
||||
return handlebars.compile(src)({a:'a'})
|
||||
}
|
||||
})
|
||||
]
|
||||
});
|
||||
const code = await getCode(bundle, output, true);
|
||||
debugPrintOutput('handlebars',code);
|
||||
t.snapshot(code);
|
||||
});
|
||||
|
||||
|
||||
// TODO various parameters
|
||||
// - format: cjs, iifi, ...
|
||||
// - sourcemap: inline, false, (and the various exotic sourcemap options)
|
||||
// Watch mode tests would be its own dir
|
||||
// ...
|
||||
Reference in New Issue
Block a user