Skip to content
Permalink
Browse files
fix(core): formatted tag function correctly removes new line charac…
…ters from the output
  • Loading branch information
jan-molak committed Feb 13, 2019
1 parent f604bd2 commit 41e9db3acc7f348c711778509a7e664aa7be9ed6
Showing with 12 additions and 2 deletions.
  1. +11 −1 packages/assertions/spec/Ensure.spec.ts
  2. +1 −1 packages/core/src/io/formatted.ts
@@ -3,7 +3,7 @@ import { given } from 'mocha-testdata';

import { expect } from '@integration/testing-tools';
import { Actor, AssertionError, KnowableUnknown } from '@serenity-js/core';
import { Ensure } from '../src';
import { Ensure, equals } from '../src';
import { isIdenticalTo, p, q } from './fixtures';

/** @test {Ensure} */
@@ -30,12 +30,22 @@ describe('Ensure', () => {
expect(Ensure.that(4, isIdenticalTo(7)).toString()).to.equal(`#actor ensures that 4 does have value identical to 7`);
});

/** @test {Ensure.that} */
it('provides a description of the assertion being made, while correctly cleaning the output from new line characters', () => {
expect(Ensure.that({ person: { name: 'Jan' }}, equals({
person: {
name: 'Jan',
},
})).toString()).to.equal(`#actor ensures that { person: { name: 'Jan' } } does equal { person: { name: 'Jan' } }`);
});

given<KnowableUnknown<number>>(
42,
p(42),
q(42),
q(p(42)),
).
/** @test {Ensure.that} */
it('allows for the actual to be a KnowableUnknown<T> as it compares its value', (actual: KnowableUnknown<number>) => {
return expect(Enrique.attemptsTo(
Ensure.that(actual, isIdenticalTo(42)),
@@ -51,7 +51,7 @@ function descriptionOf(value: KnowableUnknown<any>): string {
return value.toString();
}

return inspect(value);
return inspect(value, { breakLength: Infinity, compact: true, sorted: false }).replace(/\r?\n/g, '');
}

/**

0 comments on commit 41e9db3

Please sign in to comment.