Skip to content

Commit

Permalink
fix(assertions): corrected how the interaction to Check is reported
Browse files Browse the repository at this point in the history
Closes #713
  • Loading branch information
jan-molak committed Dec 15, 2020
1 parent 6c7abcc commit fca99a6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions packages/assertions/spec/Check.spec.ts
@@ -1,9 +1,10 @@
import 'mocha';

import { expect } from '@integration/testing-tools';
import { actorCalled, Interaction, Log, Note, Question, Task } from '@serenity-js/core';
import { actorCalled, Interaction } from '@serenity-js/core';
import * as sinon from 'sinon';

import { Check, equals, startsWith } from '../src';
import { isIdenticalTo } from './fixtures';

/** @test {Check} */
describe('Check', () => {
Expand Down Expand Up @@ -82,4 +83,23 @@ describe('Check', () => {
}),
);
});

describe('reporting', () => {

/** @test {Check.whether} */
/** @test {Check#whether} */
it('provides a description of the check', () => {
expect(Check.whether(4, isIdenticalTo(7)).andIfSo().toString()).to.equal(`#actor checks whether 4 does have value identical to 7`);
});

/** @test {Check.whether} */
/** @test {Check#whether} */
it('provides a description of the check while correctly cleaning the output from new line characters', () => {
expect(Check.whether({ person: { name: 'Jan' }}, equals({
person: {
name: 'Jan',
},
})).andIfSo().toString()).to.equal(`#actor checks whether { "person": { "name": "Jan" } } does equal { "person": { "name": "Jan" } }`);
});
})
});
2 changes: 1 addition & 1 deletion packages/assertions/src/Check.ts
Expand Up @@ -100,6 +100,6 @@ export class Check<Actual> extends Task {
* @returns {string}
*/
toString(): string {
return formatted `#actor ensures that ${ this.actual } does ${ this.expectation }`;
return formatted `#actor checks whether ${ this.actual } does ${ this.expectation }`;
}
}

0 comments on commit fca99a6

Please sign in to comment.