Skip to content
Permalink
Browse files
fix(console-reporter): advises the developer if they've instantiated …
…the reporter incorrectly

Closes #413
  • Loading branch information
jan-molak committed Feb 3, 2020
1 parent e2f596f commit 5709e76c7a97273f21b122f90c21fd8e8d3e1389
Showing 2 changed files with 17 additions and 1 deletion.
@@ -29,6 +29,19 @@ describe('ConsoleReporter', () => {
stage.assign(reporter);
});

describe('when instantiated', () => {

it(`complains when not given a printer`, () => {
expect(() => new ConsoleReporter(null, new ThemeForMonochromaticTerminals()))
.to.throw(Error, 'printer should be defined');
});

it(`complains when not given a theme`, () => {
expect(() => new ConsoleReporter(new Printer(), null))
.to.throw(Error, 'theme should be defined');
});
});

describe('when the scenario passes', () => {

/** @test {ConsoleReporter} */
@@ -29,7 +29,7 @@ import {
Timestamp,
} from '@serenity-js/core/lib/model';
import { Instance as ChalkInstance } from 'chalk';
import { match } from 'tiny-types';
import { ensure, isDefined, isInstanceOf, match } from 'tiny-types';
import { Printer } from './Printer';
import { Summary } from './Summary';
import { SummaryFormatter } from './SummaryFormatter';
@@ -156,6 +156,9 @@ export class ConsoleReporter implements StageCrewMember {
private readonly theme: TerminalTheme,
private readonly stage: Stage = null,
) {
ensure('printer', printer, isDefined());
ensure('theme', theme, isDefined());

this.summaryFormatter = new SummaryFormatter(this.theme);
}

0 comments on commit 5709e76

Please sign in to comment.