Skip to content

Commit 59527bf

Browse files
committed
more reliable HMR test cases
1 parent 2829516 commit 59527bf

5 files changed

Lines changed: 9 additions & 17 deletions

File tree

test/hotCases/chunks/dynamic-system-import/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ it("should import a changed chunk (dynamic import)", function(done) {
44
}
55
load(1).then(function(chunk) {
66
chunk.value.should.be.eql(1);
7-
NEXT(require("../../update")(done));
8-
setTimeout(function() {
7+
NEXT(require("../../update")(done, true, function() {
98
chunk.value.should.be.eql(2);
109
load(2).then(function(chunk2) {
1110
chunk2.value.should.be.eql(2);
1211
done();
1312
}).catch(done);
14-
}, 300);
13+
}));
1514
}).catch(done);
1615
});

test/hotCases/chunks/system-import/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ it("should import a changed chunk", function(done) {
33
chunk.value.should.be.eql(1);
44
chunk.value2.should.be.eql(3);
55
chunk.counter.should.be.eql(0);
6-
NEXT(require("../../update")(done));
7-
setTimeout(function() {
6+
NEXT(require("../../update")(done, true, function() {
87
chunk.value.should.be.eql(2);
98
chunk.value2.should.be.eql(4);
109
chunk.counter.should.be.eql(1);
@@ -14,6 +13,6 @@ it("should import a changed chunk", function(done) {
1413
chunk2.counter.should.be.eql(0);
1514
done();
1615
}).catch(done);
17-
}, 300);
16+
}));
1817
}).catch(done);
1918
});

test/hotCases/errors/events/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@ it("should fire the correct events", function(done) {
1414
};
1515

1616
function waitForUpdate(fn) {
17-
NEXT(require("../../update")(done, options));
18-
setTimeout(function() {
17+
NEXT(require("../../update")(done, options, function() {
1918
try {
2019
fn();
2120
} catch(e) { done(e); }
22-
}, 300);
21+
}));
2322
}
2423

2524
waitForUpdate(function() {

test/hotCases/errors/unaccepted-ignored/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@ var options = { ignoreUnaccepted: true };
55

66
it("should ignore unaccepted module updates", function(done) {
77
function waitForUpdate(fn) {
8-
NEXT(require("../../update")(done, options));
9-
setTimeout(function() {
10-
try {
11-
fn();
12-
} catch(e) { done(e); }
13-
}, 300);
8+
NEXT(require("../../update")(done, options, fn));
149
}
1510

1611
a.should.be.eql(2);

test/hotCases/update.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
module.exports = function(done, options) {
1+
module.exports = function(done, options, callback) {
22
return function() {
3-
module.hot.check(options || true).catch(function(err) {
3+
module.hot.check(options || true).then(callback || function() {}).catch(function(err) {
44
done(err);
55
});
66
}

0 commit comments

Comments
 (0)