-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathindex.js
40 lines (36 loc) · 1.08 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const assert = require("assert");
const { rollup } = require("rollup");
const { string } = require("../");
process.chdir("test");
describe("rollup-plugin-string", () => {
it("should stringify importing template", () => {
return rollup({
input: "fixtures/basic.js",
plugins: [string({ include: "**/*.html" })]
})
.then(bundle => bundle.generate({ format: "iife", moduleName: "tpl" }))
.then(({ code }) => {
new Function("assert", code)(assert);
});
});
it("should output empty sourcemap", () => {
return rollup({
input: "fixtures/basic.js",
plugins: [string({ include: "**/*.html" })]
})
.then(bundle => bundle.generate({ format: "esm", sourceMap: true }))
.then(({ output }) => {
const [{ code, map }] = output;
assert.ok(code);
assert.ok(map == null);
});
});
it("throws when include is not specified", () => {
assert.throws(() => {
rollup({
input: "fixtures/basic.js",
plugins: [string()]
});
}, /include option should be specified/);
});
});