11'use strict' ; // necessary for es6 output in node
22
33import { browser , element , by } from 'protractor/globals' ;
4- import { sendKeys } from '../protractor-helpers' ;
54
65describe ( 'Lifecycle hooks' , function ( ) {
76
@@ -44,18 +43,13 @@ describe('Lifecycle hooks', function () {
4443
4544 expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm can sing' ) ;
4645 expect ( changeLogEles . count ( ) ) . toEqual ( 2 , 'should start with 2 messages' ) ;
47- // heroNameInputEle.sendKeys('-foo-').then(function () {
48- sendKeys ( heroNameInputEle , '-foo-' ) . then ( function ( ) {
49- expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm-foo- can sing' ) ;
50- expect ( changeLogEles . count ( ) ) . toEqual ( 2 , 'should still have 2 messages' ) ;
51- // protractor bug with sendKeys means that line below does not work.
52- // return powerInputEle.sendKeys('-bar-');
53- return sendKeys ( powerInputEle , '-bar-' ) ;
54- } ) . then ( function ( ) {
55- expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm-foo- can sing-bar-' ) ;
56- // 7 == 2 previously + length of '-bar-'
57- expect ( changeLogEles . count ( ) ) . toEqual ( 7 , 'should have 7 messages now' ) ;
58- } ) ;
46+ heroNameInputEle . sendKeys ( '-foo-' ) ;
47+ expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm-foo- can sing' ) ;
48+ expect ( changeLogEles . count ( ) ) . toEqual ( 2 , 'should still have 2 messages' ) ;
49+ powerInputEle . sendKeys ( '-bar-' ) ;
50+ expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm-foo- can sing-bar-' ) ;
51+ // 7 == 2 previously + length of '-bar-'
52+ expect ( changeLogEles . count ( ) ) . toEqual ( 7 , 'should have 7 messages now' ) ;
5953 } ) ;
6054
6155 it ( 'should support DoCheck hook' , function ( ) {
@@ -72,17 +66,15 @@ describe('Lifecycle hooks', function () {
7266 // 3 messages to start
7367 expect ( count ) . toEqual ( 3 , 'should start with 3 messages' ) ;
7468 logCount = count ;
75- // heroNameInputEle.sendKeys('-foo-').then(function () {
76- return sendKeys ( heroNameInputEle , '-foo-' ) ;
69+ return heroNameInputEle . sendKeys ( '-foo-' ) ;
7770 } ) . then ( function ( ) {
7871 expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm-foo- can sing' ) ;
7972 return changeLogEles . count ( ) ;
8073 } ) . then ( function ( count : number ) {
8174 // one more for each keystroke
8275 expect ( count ) . toEqual ( logCount + 5 , 'should add 5 more messages' ) ;
8376 logCount = count ;
84- // return powerInputEle.sendKeys('-bar-');
85- return sendKeys ( powerInputEle , '-bar-' ) ;
77+ return powerInputEle . sendKeys ( '-bar-' ) ;
8678 } ) . then ( function ( ) {
8779 expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm-foo- can sing-bar-' ) ;
8880 expect ( changeLogEles . count ( ) ) . toEqual ( logCount + 6 , 'should add 6 more messages' ) ;
@@ -102,14 +94,14 @@ describe('Lifecycle hooks', function () {
10294
10395 logEles . count ( ) . then ( function ( count : number ) {
10496 logCount = count ;
105- return sendKeys ( childViewInputEle , '-test-' ) ;
97+ return childViewInputEle . sendKeys ( '-test-' ) ;
10698 } ) . then ( function ( ) {
10799 expect ( childViewInputEle . getAttribute ( 'value' ) ) . toContain ( '-test-' ) ;
108100 expect ( commentEle . isPresent ( ) ) . toBe ( true , 'should have comment because >10 chars' ) ;
109101 expect ( commentEle . getText ( ) ) . toContain ( 'long name' ) ;
110102 return logEles . count ( ) ;
111103 } ) . then ( function ( count : number ) {
112- expect ( logCount + 6 ) . toEqual ( count , '6 additional log messages should have been added' ) ;
104+ expect ( logCount + 5 ) . toEqual ( count , '5 additional log messages should have been added' ) ;
113105 logCount = count ;
114106 return buttonEle . click ( ) ;
115107 } ) . then ( function ( ) {
@@ -131,7 +123,7 @@ describe('Lifecycle hooks', function () {
131123
132124 logEles . count ( ) . then ( function ( count : number ) {
133125 logCount = count ;
134- return sendKeys ( childViewInputEle , '-test-' ) ;
126+ return childViewInputEle . sendKeys ( '-test-' ) ;
135127 } ) . then ( function ( ) {
136128 expect ( childViewInputEle . getAttribute ( 'value' ) ) . toContain ( '-test-' ) ;
137129 expect ( commentEle . isPresent ( ) ) . toBe ( true , 'should have comment because >10 chars' ) ;
@@ -154,7 +146,7 @@ describe('Lifecycle hooks', function () {
154146 let logEles = element . all ( by . css ( 'spy-parent h4 ~ div' ) ) ;
155147 expect ( heroEles . count ( ) ) . toBe ( 2 , 'should have two heroes displayed' ) ;
156148 expect ( logEles . count ( ) ) . toBe ( 2 , 'should have two log entries' ) ;
157- sendKeys ( inputEle , '-test-' ) . then ( function ( ) {
149+ inputEle . sendKeys ( '-test-' ) . then ( function ( ) {
158150 return addHeroButtonEle . click ( ) ;
159151 } ) . then ( function ( ) {
160152 expect ( heroEles . count ( ) ) . toBe ( 3 , 'should have added one hero' ) ;
0 commit comments