/**
 * @typedef {import('../runner.cjs')} Runner
 */

/**
 * @module Min
 */
/**
 * Module dependencies.
 */

import { Base } from "./base.js";
import Runner from "../runner.cjs";

var { constants } = Runner;
var EVENT_RUN_END = constants.EVENT_RUN_END;
var EVENT_RUN_BEGIN = constants.EVENT_RUN_BEGIN;

class Min extends Base {
  static description = "essentially just a summary";

  /**
   * Constructs a new `Min` reporter instance.
   *
   * @description
   * This minimal test reporter is best used with '--watch'.
   *
   * @public
   * @memberof Mocha.reporters
   * @extends Mocha.reporters.Base
   * @param {Runner} runner - Instance triggers reporter actions.
   * @param {Object} [options] - runner options
   */
  constructor(runner, options) {
    super(runner, options);

    runner.on(EVENT_RUN_BEGIN, function () {
      // clear screen
      process.stdout.write("\u001b[2J");
      // set cursor position
      process.stdout.write("\u001b[1;3H");
    });

    runner.once(EVENT_RUN_END, (...args) => this.epilogue(...args));
  }
}

export { Min };
