Skip to content

Commit 6296357

Browse files
author
Simon Renoult
committed
refactor: lessen commit number to fasten tests execution
1 parent 09ec02c commit 6296357

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"prepare": "npm run lint && npm run build",
2626
"postversion": "git push --tags",
2727
"pretest": "npm run lint",
28-
"test": "mocha --timeout=5000 --require ts-node/register test/**/*.ts",
28+
"test": "mocha --require ts-node/register test/**/*.ts",
2929
"test:ci": "nyc --reporter=lcov npm test"
3030
},
3131
"keywords": [

test/lib/statistics.test.ts

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ describe("Statistics", () => {
2121
it("returns the appropriate number of elements", async () => {
2222
// Given
2323
const options: Options = { ...defaultOptions, limit: 3 };
24-
new TestRepositoryFixture()
25-
.addFile({ name: "a.js", lines: 4, commits: 5 })
26-
.addFile({ name: "b.js", lines: 3, commits: 5 })
27-
.addFile({ name: "c.js", lines: 2, commits: 5 })
28-
.addFile({ name: "d.js", lines: 1, commits: 5 })
24+
await new TestRepositoryFixture()
25+
.addFile({ name: "a.js" })
26+
.addFile({ name: "b.js" })
27+
.addFile({ name: "c.js" })
28+
.addFile({ name: "d.js" })
2929
.writeOnDisk();
3030

3131
// When
@@ -44,7 +44,7 @@ describe("Statistics", () => {
4444
...defaultOptions,
4545
filter: ["*.js"],
4646
};
47-
new TestRepositoryFixture()
47+
await new TestRepositoryFixture()
4848
.addFile({ name: "a.js" })
4949
.addFile({ name: "b.md" })
5050
.addFile({ name: "c.js" })
@@ -76,7 +76,7 @@ describe("Statistics", () => {
7676
it("returns the appropriate elements", async () => {
7777
// Given
7878
const options: Options = { ...defaultOptions, since: "2010-01-01" };
79-
new TestRepositoryFixture()
79+
await new TestRepositoryFixture()
8080
.addFile({ name: "a.js", date: "2000-01-01T00:00:00" })
8181
.addFile({ name: "b.js", date: "2020-01-01T00:00:00" })
8282
.addFile({ name: "c.js", date: "2020-01-01T00:00:00" })
@@ -108,10 +108,10 @@ describe("Statistics", () => {
108108
it("returns the appropriate elements", async () => {
109109
// Given
110110
const options: Options = { ...defaultOptions, sort: "score" };
111-
new TestRepositoryFixture()
112-
.addFile({ name: "a.js", lines: 8, commits: 4 })
113-
.addFile({ name: "b.js", lines: 6, commits: 3 })
114-
.addFile({ name: "c.js", lines: 2, commits: 100 })
111+
await new TestRepositoryFixture()
112+
.addFile({ name: "a.js", lines: 1, commits: 4 })
113+
.addFile({ name: "b.js", lines: 3, commits: 3 })
114+
.addFile({ name: "c.js", lines: 3, commits: 2 })
115115
.addFile({ name: "d.js", lines: 4, commits: 2 })
116116
.writeOnDisk();
117117

@@ -122,22 +122,22 @@ describe("Statistics", () => {
122122
// Then
123123
expect(statistics).to.deep.equal([
124124
{
125-
churn: 100,
126-
complexity: 2,
127-
path: "c.js",
128-
score: 200,
125+
churn: 3,
126+
complexity: 3,
127+
path: "b.js",
128+
score: 9,
129129
},
130130
{
131-
churn: 4,
132-
complexity: 8,
133-
path: "a.js",
134-
score: 32,
131+
churn: 2,
132+
complexity: 4,
133+
path: "d.js",
134+
score: 8,
135135
},
136136
{
137-
churn: 3,
138-
complexity: 6,
139-
path: "b.js",
140-
score: 18,
137+
churn: 2,
138+
complexity: 3,
139+
path: "c.js",
140+
score: 6,
141141
},
142142
]);
143143
});
@@ -147,7 +147,7 @@ describe("Statistics", () => {
147147
it("returns the appropriate elements", async () => {
148148
// Given
149149
const options: Options = { ...defaultOptions, sort: "complexity" };
150-
new TestRepositoryFixture()
150+
await new TestRepositoryFixture()
151151
.addFile({ name: "a.js", lines: 8 })
152152
.addFile({ name: "b.js", lines: 6 })
153153
.addFile({ name: "c.js", lines: 2 })
@@ -186,10 +186,10 @@ describe("Statistics", () => {
186186
it("returns the appropriate elements", async () => {
187187
// Given
188188
const options: Options = { ...defaultOptions, sort: "churn" };
189-
new TestRepositoryFixture()
190-
.addFile({ name: "a.js", commits: 10 })
189+
await new TestRepositoryFixture()
190+
.addFile({ name: "a.js", commits: 7 })
191191
.addFile({ name: "b.js", commits: 3 })
192-
.addFile({ name: "c.js", commits: 7 })
192+
.addFile({ name: "c.js", commits: 5 })
193193
.addFile({ name: "d.js", commits: 2 })
194194
.writeOnDisk();
195195

@@ -200,16 +200,16 @@ describe("Statistics", () => {
200200
// Then
201201
expect(statistics).to.deep.equal([
202202
{
203-
churn: 10,
203+
churn: 7,
204204
complexity: 1,
205205
path: "a.js",
206-
score: 10,
206+
score: 7,
207207
},
208208
{
209-
churn: 7,
209+
churn: 5,
210210
complexity: 1,
211211
path: "c.js",
212-
score: 7,
212+
score: 5,
213213
},
214214
{
215215
churn: 3,
@@ -225,7 +225,7 @@ describe("Statistics", () => {
225225
it("returns the appropriate elements", async () => {
226226
// Given
227227
const options: Options = { ...defaultOptions, sort: "file" };
228-
new TestRepositoryFixture()
228+
await new TestRepositoryFixture()
229229
.addFile({ name: "d.js", lines: 1, commits: 4 })
230230
.addFile({ name: "a.js", lines: 2, commits: 3 })
231231
.addFile({ name: "c.js", lines: 3, commits: 2 })

0 commit comments

Comments
 (0)