Skip to content

Commit e06b0f5

Browse files
committed
add tests for hasErrors and hasWarnings with children taken into account
1 parent a9c0bfd commit e06b0f5

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

test/Stats.unittest.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ describe("Stats", () => {
1010
describe("does have", () => {
1111
it("hasErrors", () => {
1212
const mockStats = new Stats({
13+
children: [],
1314
errors: ["firstError"],
1415
hash: "1234"
1516
});
1617
mockStats.hasErrors().should.be.ok();
1718
});
1819
it("hasWarnings", () => {
1920
const mockStats = new Stats({
21+
children: [],
2022
warnings: ["firstError"],
2123
hash: "1234"
2224
});
@@ -26,19 +28,49 @@ describe("Stats", () => {
2628
describe("does not have", () => {
2729
it("hasErrors", () => {
2830
const mockStats = new Stats({
31+
children: [],
2932
errors: [],
3033
hash: "1234"
3134
});
3235
mockStats.hasErrors().should.not.be.ok();
3336
});
3437
it("hasWarnings", () => {
3538
const mockStats = new Stats({
39+
children: [],
3640
warnings: [],
3741
hash: "1234"
3842
});
3943
mockStats.hasWarnings().should.not.be.ok();
4044
});
4145
});
46+
describe("children have", () => {
47+
it("hasErrors", () => {
48+
const mockStats = new Stats({
49+
children: [{
50+
getStats: () => new Stats({
51+
errors: ["firstError"],
52+
hash: "5678"
53+
}),
54+
}],
55+
errors: [],
56+
hash: "1234"
57+
});
58+
mockStats.hasErrors().should.be.ok();
59+
});
60+
it("hasWarnings", () => {
61+
const mockStats = new Stats({
62+
children: [{
63+
getStats: () => new Stats({
64+
warnings: ["firstError"],
65+
hash: "5678"
66+
}),
67+
}],
68+
warnings: [],
69+
hash: "1234"
70+
});
71+
mockStats.hasWarnings().should.be.ok();
72+
});
73+
});
4274
it("formatError handles string errors", () => {
4375
const mockStats = new Stats({
4476
errors: ["firstError"],

0 commit comments

Comments
 (0)