import * as lodash from 'lodash';
import * as mongoose from 'mongoose';
import { BeforeOrAfterResults, ScenarioResults, overviewInitializer } from './Results';
import { Step } from './Step';

export interface Tag {
  name: string;
  location?: {
    line?: number;
    column?: number;
  };
}

export interface Scenario {
  _id: any;
  id: string;
  featureId?: mongoose.Types.ObjectId;
  keyword: string;
  line?: number;
  name: string;
  steps?: Step[] | null;
  before: BeforeOrAfter;
  after: BeforeOrAfter;
  tags: Tag[];
  type: string;
  results: ScenarioResults;
  isFirstScenarioOutline: boolean;
  examples?: string[][];
}

export interface BeforeOrAfter {
  results: BeforeOrAfterResults;
  steps: Step[];
}

export interface TableHeader {
  cells: string[];
}

export const beforeOrAfterInitializer = (): BeforeOrAfter =>
  lodash.cloneDeep( {
    results: {
      overview: overviewInitializer,
    },
    steps: [] as Step[],
  } );
