-
-
Notifications
You must be signed in to change notification settings - Fork 269
/
counts.ts
42 lines (41 loc) · 936 Bytes
/
counts.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
* JSON object representation of {@link @tapjs/core!counts.Counts}
*/
export interface CountsJSON {
total: number
pass: number
fail?: number
skip?: number
todo?: number
complete?: number
}
/**
* Class representing a count of all the assertions in a test
*
* The {@link @tapjs/core!counts.Counts#complete} field is only used when counting tests and
* tracking their completion status.
*
* @internal
*/
export class Counts {
total: number = 0
pass: number = 0
fail: number = 0
skip: number = 0
todo: number = 0
complete: number = 0
constructor(c?: Counts | CountsJSON) {
if (c) Object.assign(this, c)
}
toJSON(): CountsJSON {
const c: CountsJSON = {
total: this.total,
pass: this.pass,
}
if (this.fail) c.fail = this.fail
if (this.todo) c.todo = this.todo
if (this.skip) c.skip = this.skip
if (this.complete) c.complete = this.complete
return c
}
}