<commit_before>import { async } from '@angular/core/testing';

import { Settings, DevSettings } from '../../src/component/interfaces';

import { Misc } from '../miscellaneous/misc';
import { configureTestBed } from './testBed';
import { generateTemplate, TemplateSettings } from './templates';
import { generateDatasourceClass } from './datasources';

export interface TestBedConfig {
  datasourceClass?: any;
  datasourceName?: string;
  datasourceSettings?: Settings | any;
  datasourceDevSettings?: DevSettings;
  templateSettings?: TemplateSettings;
  toThrow?: boolean;
  custom?: any;
}

interface MakeTestConfig {
  title: string;
  config?: TestBedConfig;
  it?: any;
  async?: boolean;
}

const generateMetaTitle = (config: TestBedConfig): string => {
  const result = [];
  if (config.templateSettings && config.templateSettings.viewportHeight) {
    result.push(`vp height = ${config.templateSettings.viewportHeight}`);
  }
  if (config.templateSettings && config.templateSettings.viewportWidth) {
    result.push(`vp width = ${config.templateSettings.viewportWidth}`);
  }
  if (config.datasourceSettings) {
    const { startIndex, bufferSize, padding, horizontal } = config.datasourceSettings;
    if (startIndex) {
      result.push(`start = ${startIndex}`);
    }
    if (bufferSize) {
      result.push(`buffer = ${bufferSize}`);
    }
    if (padding) {
      result.push(`padding = ${padding}`);
    }
    if (horizontal) {
      result.push(`HORIZONTAL`);
    }
  }
  if (config.custom) {
    const { count } = config.custom;
    if (count) {
      result.push(`count = ${count}`);
    }
  }
  let title = result.join(', ');
  title = title ? '⤷ ' + title : '';
  return title;
};

export const makeTest = (data: MakeTestConfig) => {
  describe(generateMetaTitle(data.config), () => {
    if (data.config) {
      let misc: Misc;
      let error;
      beforeEach(async(() => {
        const datasourceClass = data.config.datasourceClass ?
          data.config.datasourceClass :
          generateDatasourceClass(
            data.config.datasourceName || 'default',
            data.config.datasourceSettings,
            data.config.datasourceDevSettings
          );
        const templateData = generateTemplate(data.config.templateSettings);
        try {
          const fixture = configureTestBed(datasourceClass, templateData.template);
          misc = new Misc(fixture);
        } catch (_error) {
          error = _error && _error.message;
        }
      }));
      it(data.title, (done) => data.it(data.config.toThrow ? error : misc)(done));
    } else {
      it(data.title, data.it);
    }
  });
};
<commit_msg>custom timer for tests<commit_after>import { Settings, DevSettings } from '../../src/component/interfaces';

import { Misc } from '../miscellaneous/misc';
import { configureTestBed } from './testBed';
import { generateTemplate, TemplateSettings } from './templates';
import { generateDatasourceClass } from './datasources';

export interface TestBedConfig {
  datasourceClass?: any;
  datasourceName?: string;
  datasourceSettings?: Settings | any;
  datasourceDevSettings?: DevSettings;
  templateSettings?: TemplateSettings;
  toThrow?: boolean;
  custom?: any;
  timeout?: number;
}

interface MakeTestConfig {
  title: string;
  config?: TestBedConfig;
  it?: any;
  async?: boolean;
}

const generateMetaTitle = (config: TestBedConfig): string => {
  const result = [];
  if (config.templateSettings && config.templateSettings.viewportHeight) {
    result.push(`vp height = ${config.templateSettings.viewportHeight}`);
  }
  if (config.templateSettings && config.templateSettings.viewportWidth) {
    result.push(`vp width = ${config.templateSettings.viewportWidth}`);
  }
  if (config.datasourceSettings) {
    const { startIndex, bufferSize, padding, horizontal } = config.datasourceSettings;
    if (startIndex) {
      result.push(`start = ${startIndex}`);
    }
    if (bufferSize) {
      result.push(`buffer = ${bufferSize}`);
    }
    if (padding) {
      result.push(`padding = ${padding}`);
    }
    if (horizontal) {
      result.push(`HORIZONTAL`);
    }
  }
  if (config.custom) {
    const { count } = config.custom;
    if (count) {
      result.push(`count = ${count}`);
    }
  }
  let title = result.join(', ');
  title = title ? '⤷ ' + title : '';
  return title;
};

export const makeTest = (data: MakeTestConfig) => {
  describe(generateMetaTitle(data.config), () => {
    let _it, timeout = 2000;
    if (data.config) {
      let misc: Misc;
      let error;
      beforeEach(() => {
        const datasourceClass = data.config.datasourceClass ?
          data.config.datasourceClass :
          generateDatasourceClass(
            data.config.datasourceName || 'default',
            data.config.datasourceSettings,
            data.config.datasourceDevSettings
          );
        const templateData = generateTemplate(data.config.templateSettings);
        try {
          const fixture = configureTestBed(datasourceClass, templateData.template);
          misc = new Misc(fixture);
        } catch (_error) {
          error = _error && _error.message;
        }
      });
      _it = (done) => data.it(data.config.toThrow ? error : misc)(done);
      timeout = data.config.timeout || timeout;
    } else {
      _it = data.it;
    }
    it(data.title, _it, timeout);
  });
};

{'fraction_non_alphanumeric': 0.13514001806684733, 'fraction_numerical': 0.0007226738934056008, 'mean_word_length': 2.698062792251169, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5871944', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1588, 'n_words': 333}