Skip to content

Commit

Permalink
fix unittests
Browse files Browse the repository at this point in the history
  • Loading branch information
Idrinth committed May 26, 2021
1 parent c8b8171 commit 0ac0446
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/reporter/console-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const cli: Reporter = (results: {[id: string]: FinishedSet},): void => {
'median 80%',
'min 80%',
'max 80%',
'stdv 80%',
'stdv 100%',
],
},);
for (const id of Object.getOwnPropertyNames(results,)) {
Expand Down
6 changes: 6 additions & 0 deletions test/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ class FakeResult implements Result, ValidationResult, FinishedSet {

public min80: number;

public stdv80: number;

public stdv100: number;

public response = {
headers: {},
cookies: {},
Expand Down Expand Up @@ -86,6 +90,8 @@ class FakeResult implements Result, ValidationResult, FinishedSet {
this.min80 = duration;
this.median100 = duration;
this.median80 = duration;
this.stdv100 = 100;
this.stdv80 = 80;
}

public add() {
Expand Down
2 changes: 2 additions & 0 deletions test/reporter/console-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ describe('reporter/console-reporter', () => {
median80: 33,
min80: 12,
max80: 99,
stdv80: 12,
stdv100: 99,
},
};
expect(() => consoleReporter(results,),).to.not.throw();
Expand Down
8 changes: 6 additions & 2 deletions test/reporter/csv-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ describe('reporter/csv-reporter', () => {
median80: 33,
min80: 12,
max80: 99,
stdv100: 9,
stdv80: 8,
},
};
csvReporter(results,);
Expand All @@ -55,14 +57,16 @@ describe('reporter/csv-reporter', () => {
median80: 33,
min80: 14,
max80: 99,
stdv100: 9,
stdv80: 8,
},
};
csvReporter(results,);
setTimeout(() => {
expect(readFileSync(file,) + '',).to.equal(
'id,errors,count,avg100,median100,min100,'
+ 'max100,avg80,median80,min80,max80'
+ '\n1,14,7,6,33,1,99,76,33,14,99',
+ 'max100,avg80,median80,min80,max80,stdv100,stdv80'
+ '\n1,14,7,6,33,1,99,76,33,14,99,9,8',
);
mock.restore();
done();
Expand Down
4 changes: 4 additions & 0 deletions test/reporter/json-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ describe('reporter/json-reporter', () => {
median80: 33,
min80: 12,
max80: 99,
stdv80: 99,
stdv100: 99,
},
};
jsonReporter(results,);
Expand All @@ -50,6 +52,8 @@ describe('reporter/json-reporter', () => {
median80: 33,
min80: 14,
max80: 99,
stdv80: 99,
stdv100: 99,
},
};
jsonReporter(results,);
Expand Down
2 changes: 2 additions & 0 deletions test/reporter/multi-reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ describe('reporter/multi-reporter', () => {
median80: 33,
min80: 14,
max80: 99,
stdv80: 99,
stdv100: 99,
},
};
multiReporter(results,);
Expand Down
6 changes: 6 additions & 0 deletions test/worker/calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ describe('calculator', () => {
median80: NaN,
min80: NaN,
max80: NaN,
stdv80: NaN,
stdv100: NaN,
},);
},);
it('should return a set if given data', () => {
Expand Down Expand Up @@ -60,6 +62,8 @@ describe('calculator', () => {
median80: 3,
min80: 1,
max80: 4,
stdv100: 1.224744871391589,
stdv80: 1.224744871391589,
},);
},);
it('should return a result if given data', () => {
Expand Down Expand Up @@ -102,6 +106,8 @@ describe('calculator', () => {
median80: 17,
min80: 2,
max80: 32,
stdv80: 8.611262750250173,
stdv100: 83.93449827097318,
},);
},);
},);

0 comments on commit 0ac0446

Please sign in to comment.