Skip to content

Commit 8a3ccf4

Browse files
committed
test: Add tests to ensure input directory is never modified.
1 parent 04f1f62 commit 8a3ccf4

File tree

6 files changed

+13
-17
lines changed

6 files changed

+13
-17
lines changed

packages/@css-blocks/broccoli/test/Aggregate.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as assert from "assert";
22

33
import { TempDir, createBuilder, createTempDir } from "broccoli-test-helper";
4+
import * as FSTree from "fs-tree-diff";
5+
import * as walkSync from "walk-sync";
46

57
import { CSSBlocksAggregate, Transport } from "../src/index";
68

@@ -41,8 +43,11 @@ describe("Broccoli Aggregate Plugin Test", function () {
4143
let output = createBuilder(pluginC);
4244

4345
// First pass does full compile and copies all files except block files to output.
46+
let preDiff = FSTree.fromEntries(walkSync.entries(input.path()));
4447
await output.build();
48+
let postDiff = FSTree.fromEntries(walkSync.entries(input.path()));
4549

50+
assert.equal(preDiff.calculatePatch(postDiff).length, 0, "Input directory unchanged after build.");
4651
assert.deepEqual(output.changes(), {
4752
"test.css": "create",
4853
"app.css": "create",

packages/@css-blocks/broccoli/test/Analyze.ts

+8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import * as assert from "assert";
22

33
import { GlimmerAnalyzer } from "@css-blocks/glimmer";
4+
45
import { TempDir, createBuilder, createTempDir } from "broccoli-test-helper";
6+
import * as FSTree from "fs-tree-diff";
7+
import * as walkSync from "walk-sync";
58

69
import { CSSBlocksAnalyze, Transport } from "../src/index";
710

@@ -57,7 +60,11 @@ describe("Broccoli Analyze Plugin Test", function () {
5760
));
5861

5962
// First pass does full compile and copies all files except block files to output.
63+
let preDiff = FSTree.fromEntries(walkSync.entries(input.path()));
6064
await output.build();
65+
let postDiff = FSTree.fromEntries(walkSync.entries(input.path()));
66+
67+
assert.equal(preDiff.calculatePatch(postDiff).length, 0, "Input directory unchanged after build.");
6168
assert.ok(Object.keys(transport).length, "Transport Object populated");
6269
assert.ok(transport["mapping"], "Mapping property is populated in Transport Object");
6370
assert.ok(transport["blocks"], "Blocks property is populated in Transport Object");
@@ -79,6 +86,7 @@ describe("Broccoli Analyze Plugin Test", function () {
7986
}}}},
8087
});
8188
await output.build();
89+
assert.equal(preDiff.calculatePatch(postDiff).length, 0, "Input directory unchanged after rebuild.");
8290
assert.equal(transport["css"], ".a { color: blue; } .b { color: yellow; }", "Modifications to block files trigger build but result in no output tree changes.");
8391
assert.deepEqual(output.changes(), {}, "Modifications to block files trigger build but result in no output tree changes.");
8492

packages/@css-blocks/ember-cli/tests/dummy/app/router.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Router.map(function() {
1414
this.route('addon-component');
1515
this.mount('in-repo-engine');
1616
this.mount('in-repo-lazy-engine');
17-
this.route('node-modules-resolution');
1817
});
1918

2019
export default Router;

packages/@css-blocks/ember-cli/tests/dummy/app/styles/node-modules-resolution.block.css

-5
This file was deleted.

packages/@css-blocks/ember-cli/tests/dummy/app/templates/application.hbs

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
<li>
2525
{{#link-to "in-repo-lazy-engine" class="test-nav-item"}}In Repo Lazy Engine{{/link-to}}
2626
</li>
27-
<li>
28-
{{#link-to "node-modules-resolution" class="test-nav-item"}}Node Module Resolution{{/link-to}}
29-
</li>
3027
</ul>
3128
</nav>
3229

packages/@css-blocks/ember-cli/tests/dummy/app/templates/node-modules-resolution.hbs

-8
This file was deleted.

0 commit comments

Comments
 (0)