Skip to content

Commit 379d0e9

Browse files
author
Elrey Belmonti
committed
refactor test according to PR comments
1 parent 79d79ce commit 379d0e9

File tree

4 files changed

+29
-80
lines changed

4 files changed

+29
-80
lines changed

test/dashboard/index.spec.js

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,48 +5,24 @@ require("../base.spec");
55
const Dashboard = require("../../dashboard");
66

77
describe("dashboard", () => {
8-
let dashboard;
9-
let dashboardWithOptions;
108
const options = {
119
color: "red",
1210
minimal: true,
1311
title: "my-title"
1412
};
1513

16-
beforeEach(() => {
17-
dashboard = new Dashboard();
18-
dashboardWithOptions = new Dashboard(options);
19-
});
20-
21-
it("can create a new dashboard", () => {
14+
it("can create a new no option dashboard", () => {
15+
const dashboard = new Dashboard();
2216
expect(dashboard).to.be.ok;
17+
expect(dashboard.color).to.equal("green");
18+
expect(dashboard.minimal).to.be.false;
19+
expect(dashboard.stats).to.be.null;
2320
});
2421

25-
describe("#color", () => {
26-
it("has default color of 'green'", () => {
27-
expect(dashboard.color).to.equal("green");
28-
});
29-
30-
context("when given option color red", () => {
31-
it("has color set to 'red'", () => {
32-
expect(dashboardWithOptions.color).to.equal("red");
33-
});
34-
});
35-
});
36-
37-
describe("#minimal", () => {
38-
it("has default minimal set to 'false", () => {
39-
expect(dashboard.minimal).to.be.false;
40-
});
41-
42-
context("when given opiton minimal", () => {
43-
it("has minimal set to 'true'", () => {
44-
expect(dashboardWithOptions.minimal).to.be.true;
45-
});
46-
});
47-
});
48-
49-
it("has default stats of 'null'", () => {
50-
expect(dashboard.stats).to.be.null;
22+
it("can create a new with options dashboard", () => {
23+
const dashboardWithOptions = new Dashboard(options);
24+
expect(dashboardWithOptions).to.be.ok;
25+
expect(dashboardWithOptions.color).to.equal("red");
26+
expect(dashboardWithOptions.minimal).to.be.true;
5127
});
5228
});

test/plugin/index.spec.js

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,52 +3,25 @@
33
const Plugin = require("../../plugin");
44

55
describe("plugin", () => {
6-
let plugin;
7-
let pluginWithOptions;
86
const options = {
97
port: 3000,
108
host: "111.0.2.3"
119
};
1210

13-
beforeEach(() => {
14-
plugin = new Plugin();
15-
pluginWithOptions = new Plugin(options);
16-
});
17-
18-
it("can create a new plugin", () => {
11+
it("can create a new no option plugin", () => {
12+
const plugin = new Plugin();
1913
expect(plugin).to.be.ok;
20-
});
21-
22-
describe("#host", () => {
23-
it("has a default host of '127.0.0.1'", () => {
24-
expect(plugin.host).to.equal("127.0.0.1");
25-
});
26-
27-
context("when given option host '111.0.2.3'", () => {
28-
it("has host set to 111.0.2.3", () => {
29-
expect(pluginWithOptions.host).to.equal("111.0.2.3");
30-
});
31-
});
32-
});
33-
34-
describe("#port", () => {
35-
it("has a default port of '9838'", () => {
36-
// eslint-disable-next-line no-magic-numbers
37-
expect(plugin.port).to.equal(9838);
38-
});
39-
context("when given option port '3000'", () => {
40-
it("has port set to 3000", () => {
41-
// eslint-disable-next-line no-magic-numbers
42-
expect(pluginWithOptions.port).to.equal(3000);
43-
});
44-
});
45-
});
46-
47-
it("has a default handler of 'null'", () => {
14+
expect(plugin.host).to.equal("127.0.0.1");
15+
// eslint-disable-next-line no-magic-numbers
16+
expect(plugin.port).to.equal(9838);
4817
expect(plugin.handler).to.be.null;
18+
expect(plugin.watching).to.be.false;
4919
});
5020

51-
it("has a default watching of 'false'", () => {
52-
expect(plugin.watching).to.be.false;
21+
it("can create a new with options dashboard", () => {
22+
const pluginWithOptions = new Plugin(options);
23+
expect(pluginWithOptions.host).to.equal("111.0.2.3");
24+
// eslint-disable-next-line no-magic-numbers
25+
expect(pluginWithOptions.port).to.equal(3000);
5326
});
5427
});

test/utils/format-assets.spec.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ describe("format-assets.js", () => {
3434
it("returns a nested array of assets information", () => {
3535
const assetList = [
3636
{
37-
name: "assest1",
37+
name: "assets1",
3838
size: 500
3939
},
4040
{
41-
name: "assest2",
41+
name: "assets2",
4242
size: 0
4343
},
4444
{
45-
name: "assest2",
45+
name: "assets2",
4646
size: 500
4747
}
4848
];
4949

5050
const output = [
5151
["Name", "Size"],
52-
["assest1", "500 B"],
53-
["assest2", "0 B"],
54-
["assest2", "500 B"],
52+
["assets1", "500 B"],
53+
["assets2", "0 B"],
54+
["assets2", "500 B"],
5555
["Total", "1000 B"]
5656
];
5757
expect(_printAssets(assetList)).eql(output);

test/utils/format-output.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ describe("format-output.js", () => {
2020
});
2121

2222
describe("#_formatMessage", () => {
23-
const message1 = "Module build failed: SyntaxError: missing ; before statement";
24-
const message2 = "/Module not found: Error: Cannot resolve 'file' or 'directory'/";
2523
it("returns a readable user friendly message", () => {
24+
const message1 = "Module build failed: SyntaxError: missing ; before statement";
25+
const message2 = "/Module not found: Error: Cannot resolve 'file' or 'directory'/";
2626
expect(_formatMessage(message1)).to.equal("Syntax error: missing ; before statement");
2727
expect(_formatMessage(message2)).to.equal("/Module not found:/");
2828
});

0 commit comments

Comments
 (0)