Skip to content
Permalink
Browse files
fix(protractor): Corrected how Text.of(Target) is represented in the …
…reports
  • Loading branch information
jan-molak committed Feb 5, 2019
1 parent 68efd68 commit ae91f957168f085153e21f770066e15cd0e52279
Showing with 18 additions and 3 deletions.
  1. +17 −2 packages/protractor/spec/screenplay/questions/Text.spec.ts
  2. +1 −1 packages/protractor/src/screenplay/questions/Text.ts
@@ -1,3 +1,4 @@
import { expect } from '@integration/testing-tools';
import { Ensure, equals } from '@serenity-js/assertions';
import { Actor } from '@serenity-js/core';
import { by, protractor } from 'protractor';
@@ -13,6 +14,8 @@ describe('Text', function() {

describe('of', () => {

const Header = Target.the('header').located(by.tagName('h1'));

/** @test {Text} */
/** @test {Text.of} */
it('allows the actor to read the text of the DOM element matching the locator', () => Bernie.attemptsTo(
@@ -24,12 +27,19 @@ describe('Text', function() {
</html>
`)),

Ensure.that(Text.of(Target.the('header').located(by.tagName('h1'))), equals('Hello World!')),
Ensure.that(Text.of(Header), equals('Hello World!')),
));

it(`produces sensible description of the question being asked`, () => {
expect(Text.of(Target.the('header').located(by.tagName('h1'))).toString())
.to.equal('the text of the header');
});
});

describe('ofAll', () => {

const Shopping_List_Items = Target.all('shopping list items').located(by.css('li'));

/** @test {Text} */
/** @test {Text.ofAll} */
it('allows the actor to read the text of all DOM elements matching the locator', () => Bernie.attemptsTo(
@@ -45,7 +55,12 @@ describe('Text', function() {
</html>
`)),

Ensure.that(Text.ofAll(Target.all('shopping list items').located(by.css('li'))), equals(['milk', 'oats'])),
Ensure.that(Text.ofAll(Shopping_List_Items), equals(['milk', 'oats'])),
));

it(`produces sensible description of the question being asked`, () => {
expect(Text.ofAll(Shopping_List_Items).toString())
.to.equal('the text of all the shopping list items');
});
});
});
@@ -39,6 +39,6 @@ class TextOfMultipleElements extends Text<ElementArrayFinder, string[]> {
}

toString() {
return `the text of all ${ this.target }`;
return `the text of ${ this.target }`;
}
}

0 comments on commit ae91f95

Please sign in to comment.