import * as path from 'path';

import { TestCase } from './test-case';

export abstract class TestSuite {
  protected name: string;
  protected path = path;

  public testCases: TestCase[] = [];

  constructor() {
    this.name = path.basename(__filename);
    this.init();
  }

  public addTestCase(testCase: TestCase) {
    this.testCases.push(testCase);
  }
  public addAllTestCases(testCases: TestCase[]) {
    this.testCases.push(...testCases);
  }

  protected abstract init(): void;

  beforeAll() { }

  run(): void {

    before(() => {
      this.beforeAll();
    });

    describe(this.name, () => {
      let tcAtual: TestCase;

      beforeEach(() => {
      });

      for (const tc of this.testCases) {
        tcAtual = tc;
        it(tc.name,  () => {
          tc.run();
        });
      }

    });
  }
}
