'use strict';

const join = require('path').join;
const ProfileRunner = require(join(__appRoot, 'src/profile-runner'));
const VERBOSITY = require(join(__appRoot, 'src/support/verbosity'));
const chalk = require('chalk');

class Reporter {
  /**
  * @param {TestRunner} testRunner The test runner
  * @param {number} verbosity The verbosity level
  */
  constructor(testRunner, verbosity) {
    this.verbosity = verbosity;
    testRunner.on(ProfileRunner.START, (profiles) => {
      console.info(`Executing ${profiles.length} profile${profiles.length === 1 ? '' : 's'}.\n`);
    });

    testRunner.on(ProfileRunner.END, (profiles) => {
      console.log(`Finished ${profiles.length} profiles.`);
    });

    testRunner.on(ProfileRunner.PROFILE_START, (profile) => {
      if (this.verbosity >= VERBOSITY.NORMAL) {
        console.info(`${profile.description()}`);
      }
    });

    testRunner.on(ProfileRunner.PROFILE_END, (profile, result) => {
      if (this.verbosity >= VERBOSITY.NORMAL) {
        const best = result.testResults
          .sort((a, b) => a.averageTime - b.averageTime)[0];
        console.info(chalk.green(`  Winner: "${best.func.description()}" (${best.averageTime.toFixed(3)}ms)\n`));
      }
    });

    testRunner.on(ProfileRunner.TEST_START, (profile, func) => {
      if (this.verbosity >= VERBOSITY.NORMAL) {
        console.log(chalk.green(`  ${func.description()}`));
      }
    });

    testRunner.on(ProfileRunner.TEST_END, (profile, func, result) => {
      if (this.verbosity >= VERBOSITY.NORMAL) {
        console.info(`    ${result.averageTime.toFixed(3)}ms`);
        console.info();
      }
    });

    testRunner.on(ProfileRunner.ERROR, (err) => {
      console.error(err.stack);
    });
  }
}

module.exports = Reporter;

@@ -254,20 +254,23 @@
 am %7B
-Test
+Profile
 Runner%7D 
 test
@@ -265,20 +265,23 @@
 Runner%7D 
-test
+profile
 Runner T
@@ -364,20 +364,23 @@
 tructor(
-test
+profile
 Runner, 
@@ -424,28 +424,31 @@
 bosity;%0A    
-test
+profile
 Runner.on(Pr
@@ -585,36 +585,39 @@
 );%0A    %7D);%0A%0A    
-test
+profile
 Runner.on(Profil
@@ -710,36 +710,39 @@
 );%0A    %7D);%0A%0A    
-test
+profile
 Runner.on(Profil
@@ -890,36 +890,39 @@
  %7D%0A    %7D);%0A%0A    
-test
+profile
 Runner.on(Profil
@@ -1241,36 +1241,39 @@
  %7D%0A    %7D);%0A%0A    
-test
+profile
 Runner.on(Profil
@@ -1435,36 +1435,39 @@
  %7D%0A    %7D);%0A%0A    
-test
+profile
 Runner.on(Profil
@@ -1670,20 +1670,23 @@
 );%0A%0A    
-test
+profile
 Runner.o

Fix naming