forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHotModuleReplacementPlugin.test.js
More file actions
56 lines (54 loc) · 1.76 KB
/
HotModuleReplacementPlugin.test.js
File metadata and controls
56 lines (54 loc) · 1.76 KB
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
var should = require("should");
var path = require("path");
var fs = require("fs");
var webpack = require("../");
describe("HotModuleReplacementPlugin", function() {
it("should not have circular hashes but equal if unmodified", function(done) {
var entryFile = path.join(__dirname, "js", "entry.js");
var recordsFile = path.join(__dirname, "js", "records.json");
try { fs.mkdirSync(path.join(__dirname, "js")); } catch(e) {}
try { fs.unlinkSync(recordsFile); } catch(e) {}
var compiler = webpack({
entry: entryFile,
recordsPath: recordsFile,
output: {
path: path.join(__dirname, "js")
},
hot: true
});
fs.writeFileSync(entryFile, "1", "utf-8");
compiler.run(function(err, stats) {
if(err) throw err;
var oldHash1 = stats.toJson().hash;
compiler.run(function(err, stats) {
if(err) throw err;
var lastHash1 = stats.toJson().hash;
lastHash1.should.be.eql(oldHash1);
fs.writeFileSync(entryFile, "2", "utf-8");
compiler.run(function(err, stats) {
if(err) throw err;
var lastHash2 = stats.toJson().hash;
fs.writeFileSync(entryFile, "1", "utf-8");
compiler.run(function(err, stats) {
if(err) throw err;
var currentHash1 = stats.toJson().hash;
currentHash1.should.not.be.eql(lastHash1);
fs.writeFileSync(entryFile, "2", "utf-8");
compiler.run(function(err, stats) {
if(err) throw err;
var currentHash2 = stats.toJson().hash;
compiler.run(function(err, stats) {
if(err) throw err;
stats.toJson().hash.should.be.eql(currentHash2);
currentHash2.should.not.be.eql(lastHash2);
currentHash1.should.not.be.eql(currentHash2);
lastHash1.should.not.be.eql(lastHash2);
done();
});
});
});
});
});
});
});
});