Skip to content

Commit ac9d6f3

Browse files
committed
add more HMR test cases
1 parent 358c457 commit ac9d6f3

13 files changed

Lines changed: 75 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = 1;
2+
---
3+
module.exports = 2;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var value = require("./parent-file");
2+
3+
it("should bubble update from a nested dependency", function(done) {
4+
value.should.be.eql(1);
5+
module.hot.accept("./parent-file", function() {
6+
value = require("./parent-file");
7+
value.should.be.eql(2);
8+
done();
9+
});
10+
NEXT(require("../../update")(done));
11+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("./file");
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var callback;
2+
3+
module.hot.accept();
4+
module.hot.dispose(function(data) {
5+
data.callback = callback;
6+
});
7+
8+
module.exports = function(cb) {
9+
callback = cb;
10+
}
11+
12+
---
13+
14+
module.hot.data.callback();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
it("should accept itself and pass data", function(done) {
2+
require("./file")(done);
3+
NEXT(require("../../update")(done));
4+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = 1;
2+
---
3+
module.exports = 2;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = 1;
2+
---
3+
module.exports = 2;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
var value = require("./parent-file");
2+
3+
it("should update multiple modules at the same time", function(done) {
4+
value.should.be.eql(2);
5+
module.hot.accept("./parent-file", function() {
6+
value = require("./parent-file");
7+
value.should.be.eql(4);
8+
done();
9+
});
10+
NEXT(require("../../update")(done));
11+
});

0 commit comments

Comments
 (0)