-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathplugin-test.ts
81 lines (69 loc) · 2.4 KB
/
plugin-test.ts
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import * as assert from "assert";
import * as fs from "fs-extra";
// import * as path from "path";
import { GlimmerAnalyzer } from "@css-blocks/glimmer";
import { TempDir, buildOutput, createTempDir } from "broccoli-test-helper";
import { BroccoliCSSBlocks } from "../src/index";
describe("Broccoli Plugin Test", function () {
let input: TempDir;
beforeEach(async () => {
input = await createTempDir();
});
afterEach(async () => {
await input.dispose();
});
describe("Broccoli Plugin Test", () => {
it("runs tests", () => {
assert.ok(1);
});
it("outputs CSS file and populates transport object", async () => {
const entryComponentName = "Chrisrng";
input.write({
"package.json": `{
"name": "chrisrng-test"
}`,
src: {
ui: {
components: {
[entryComponentName]: {
"template.hbs": `<div><h1 class="foo">Welcome to Glimmer!</h1></div>`,
"stylesheet.css": `
:scope {
color: red;
}
.foo {
color: green;
}
`,
},
},
},
},
});
let transport = {};
let analyzer = new GlimmerAnalyzer(input.path(), ".", {
app: { name: "test" },
types: {
stylesheet: { definitiveCollection: "components" },
template: { definitiveCollection: "components" },
},
collections: {
components: { group: "ui", types: [ "template", "stylesheet" ] },
},
});
let compiler = new BroccoliCSSBlocks(input.path(), {
entry: [entryComponentName],
output: "css-blocks.css",
transport,
analyzer,
});
let output = await buildOutput(compiler);
assert.ok(Object.keys(transport).length, "Transport Object populated");
assert.ok(transport["mapping"], "Mapping property is populated in Transport Object");
assert.ok(transport["blocks"], "Blocks property is populated in Transport Object");
assert.ok(transport["analyzer"], "Analyzer property is populated in Transport Object");
assert.ok(transport["css"], "CSS property is populated in Transport Object");
assert.equal(await fs.readFile(output.path("css-blocks.css"), "utf8"), transport["css"].content, "CSS File generated");
});
});
});