all files / core/ test-fixture.ts

95% Statements 19/20
75% Branches 3/4
100% Functions 6/6
94.12% Lines 16/17
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                      437× 437× 437× 437× 437×       315×       315×     189613×     19391× 19371×     40×      
import { ITestFixture, ITest } from "./_interfaces";
 
export class TestFixture implements ITestFixture {
 
    fixture: { [id: string]: (...args: Array<any>) => any };
 
    ignored: boolean;
    ignoreReason: string;
 
    focussed: boolean;
    tests: Array<ITest>;
 
    constructor () {
        this.focussed = false;
        this.ignored = false;
        this.ignoreReason = undefined;
        this.fixture = {};
        this.tests = [];
    }
 
    public addTest(test: ITest): void {
        // if the test is already here, don't add it
        Iif (this.tests.indexOf(test) !== -1) {
            return;
        }
 
        this.tests.push(test);
    }
 
    public getTests(): Array<ITest> {
        let anyTestsFocussed = this.tests.filter(t => t.focussed).length > 0;
 
        // if there are no tests focussed, return them all
        if (!anyTestsFocussed) {
            return this.tests;
        }
 
        return this.tests.filter(t => t.focussed);
    }
 
}