Skip to content

Commit 5a71653

Browse files
committed
Start with reporter tests
Ref #121
1 parent ed75ac1 commit 5a71653

File tree

3 files changed

+64
-1
lines changed

3 files changed

+64
-1
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
"express": "^4.14.0",
1717
"file-loader": "^0.9.0",
1818
"mocha": "^3.0.2",
19+
"mocha-sinon": "^1.1.6",
1920
"should": "^11.1.0",
21+
"sinon": "^1.17.5",
2022
"supertest": "^2.0.0",
2123
"webpack": "^2.1.0-beta.22"
2224
},

test/Advanced.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var options = {
66
publicPath: "/public/"
77
};
88

9-
describe.only("Advanced API", function() {
9+
describe("Advanced API", function() {
1010

1111
var plugins = {};
1212
var invalidationCount = 0;

test/Reporter.test.js

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
var middleware = require("../middleware");
2+
var should = require("should");
3+
require("mocha-sinon");
4+
5+
describe("Reporter", function() {
6+
var plugins = {};
7+
var compiler = {
8+
watch: function() {
9+
return {};
10+
},
11+
plugin: function(name, callback) {
12+
plugins[name] = callback;
13+
}
14+
};
15+
beforeEach(function() {
16+
plugins = {};
17+
this.sinon.stub(console, 'log');
18+
this.sinon.stub(console, 'info');
19+
});
20+
21+
it("should show valid message", function(done) {
22+
middleware(compiler);
23+
var stats = {
24+
hasErrors: function() {
25+
return false;
26+
},
27+
hasWarnings: function() {
28+
return false;
29+
}
30+
};
31+
32+
plugins.done(stats);
33+
setTimeout(function() {
34+
should.strictEqual(console.log.callCount, 1);
35+
// TODO: test stats output
36+
should.strictEqual(console.info.callCount, 1);
37+
should.strictEqual(console.info.calledWith("webpack: bundle is now VALID."), true);
38+
done();
39+
});
40+
});
41+
42+
it("should show invalid message", function(done) {
43+
middleware(compiler);
44+
var stats = {
45+
hasErrors: function() {
46+
return false;
47+
},
48+
hasWarnings: function() {
49+
return false;
50+
}
51+
};
52+
53+
plugins.done(stats);
54+
plugins.invalid();
55+
setTimeout(function() {
56+
should.strictEqual(console.info.callCount, 1);
57+
should.strictEqual(console.info.calledWith("webpack: bundle is now INVALID."), true);
58+
done();
59+
});
60+
});
61+
});

0 commit comments

Comments
 (0)