all files / core/results/ test-results.ts

90.91% Statements 20/22
66.67% Branches 4/6
100% Functions 5/5
89.47% Lines 17/19
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       1049×   1312×   342×       342×       342× 340×         1049×   5044× 5044× 5044×    
import { TestCaseResult } from "./test-case-result";
import { ITest } from "../_interfaces/test.i";
import { TestOutcome } from "./test-outcome";
 
export class TestResults {
 
   private _testCaseResults: Array<TestCaseResult> = [];
 
   get outcome(): TestOutcome {
      const outcomes = this._testCaseResults.map(testCaseResult => testCaseResult.outcome);
 
      Iif (outcomes.indexOf(TestOutcome.Error) !== -1) {
         return TestOutcome.Error;
      }
 
      Iif (outcomes.indexOf(TestOutcome.Fail) !== -1) {
         return TestOutcome.Fail;
      }
 
      if (outcomes.indexOf(TestOutcome.Pass) !== -1) {
         return TestOutcome.Pass;
      }
 
      return TestOutcome.Skip;
   }
 
   public constructor(private _test: ITest) { }
 
   public addTestCaseResult(args: Array<any>, error?: Error): TestCaseResult {
      const testCaseResult = new TestCaseResult(this._test, args, error);
      this._testCaseResults.push(testCaseResult);
      return testCaseResult;
   }
}