forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecordIdsPlugin.test.js
46 lines (39 loc) · 1.09 KB
/
RecordIdsPlugin.test.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
41
42
43
44
45
46
/* globals describe, before, it */
"use strict";
const should = require("should");
const path = require("path");
const webpack = require("../lib/webpack");
const identifierUtils = require("../lib/util/identifier");
describe("RecordIdsPlugin", () => {
let compiler;
before(() => {
compiler = webpack({
entry: "./nodetest/entry",
context: path.join(__dirname, "fixtures"),
output: {
path: path.join(__dirname, "nodetest", "js"),
filename: "result1.js"
}
});
compiler.plugin("compilation", (compilation, callback) => {
compilation.plugin("should-record", () => true);
});
});
it("should cache identifiers", (done) => {
compiler.compile((err, compilation) => {
if(err) done(err);
let pass = true;
for(let i = 0; i < compilation.modules.length; i++) {
try {
should.exist(compilation.modules[i].portableId);
compilation.modules[i].portableId.should.equal(identifierUtils.makePathsRelative(compiler.context, compilation.modules[i].identifier()));
} catch(e) {
done(e);
pass = false;
break;
}
}
if(pass) done();
});
});
});