1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const errors_1 = require("../errors");
|
4 | const test_outcome_1 = require("./test-outcome");
|
5 | const stringification_1 = require("../stringification");
|
6 | const log_1 = require("../maintenance/log");
|
7 | class TestCaseResult {
|
8 | constructor(testResults, args, error = null) {
|
9 | this.testResults = testResults;
|
10 | this.args = args;
|
11 | this.error = error;
|
12 | }
|
13 | get logs() {
|
14 | const filePath = this.testResults.fixtureResult.fixture.filePath.replace(/\//g, "\\");
|
15 | const functionName = this.testResults.fixtureResult.fixture.fixture.constructor.name +
|
16 | "." +
|
17 | this.testResults.test.key;
|
18 | return log_1.Logger.LOGS.filter(x => x.stack.some(y => y.filePath === filePath && y.functionName === functionName));
|
19 | }
|
20 | get outcome() {
|
21 | if (this.error) {
|
22 | if (this.error instanceof errors_1.MatchError) {
|
23 | return test_outcome_1.TestOutcome.Fail;
|
24 | }
|
25 | return test_outcome_1.TestOutcome.Error;
|
26 | }
|
27 | if (this.testResults.test.ignored) {
|
28 | return test_outcome_1.TestOutcome.Skip;
|
29 | }
|
30 | return test_outcome_1.TestOutcome.Pass;
|
31 | }
|
32 | get description() {
|
33 | const fixture = this.testResults.fixtureResult.fixture;
|
34 | const test = this.testResults.test;
|
35 | const title = `${fixture.description} > ${test.description}`;
|
36 | if (this.args.length === 0) {
|
37 | return title;
|
38 | }
|
39 | const formattedArguments = this.args.map(stringification_1.stringify).join(", ");
|
40 | return `${title} ( ${formattedArguments} )`;
|
41 | }
|
42 | }
|
43 | exports.TestCaseResult = TestCaseResult;
|
44 |
|
\ | No newline at end of file |