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

100% Statements 22/22
100% Branches 6/6
100% Functions 5/5
100% Lines 19/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       1180×   1180×   1700×   524× 27×     497× 24×     473× 468×         5283× 5283× 5283×    
import { TestCaseResult } from "./test-case-result";
import { ITest } from "../_interfaces/test.i";
import { TestOutcome } from "./test-outcome";
 
export class TestResults {
 
   private _testCaseResults: Array<TestCaseResult> = [];
 
   public constructor(private _test: ITest) { }
 
   public get outcome(): TestOutcome {
      const outcomes = this._testCaseResults.map(testCaseResult => testCaseResult.outcome);
 
      if (outcomes.indexOf(TestOutcome.Error) !== -1) {
         return TestOutcome.Error;
      }
 
      if (outcomes.indexOf(TestOutcome.Fail) !== -1) {
         return TestOutcome.Fail;
      }
 
      if (outcomes.indexOf(TestOutcome.Pass) !== -1) {
         return TestOutcome.Pass;
      }
 
      return TestOutcome.Skip;
   }
 
   public addTestCaseResult(args: Array<any>, error?: Error): TestCaseResult {
      const testCaseResult = new TestCaseResult(this._test, args, error);
      this._testCaseResults.push(testCaseResult);
      return testCaseResult;
   }
}