1
1
'use strict' ; // necessary for es6 output in node
2
2
3
3
import { browser , element , by } from 'protractor/globals' ;
4
- import { sendKeys } from '../protractor-helpers' ;
5
4
6
5
describe ( 'Lifecycle hooks' , function ( ) {
7
6
@@ -44,18 +43,13 @@ describe('Lifecycle hooks', function () {
44
43
45
44
expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm can sing' ) ;
46
45
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' ) ;
59
53
} ) ;
60
54
61
55
it ( 'should support DoCheck hook' , function ( ) {
@@ -72,17 +66,15 @@ describe('Lifecycle hooks', function () {
72
66
// 3 messages to start
73
67
expect ( count ) . toEqual ( 3 , 'should start with 3 messages' ) ;
74
68
logCount = count ;
75
- // heroNameInputEle.sendKeys('-foo-').then(function () {
76
- return sendKeys ( heroNameInputEle , '-foo-' ) ;
69
+ return heroNameInputEle . sendKeys ( '-foo-' ) ;
77
70
} ) . then ( function ( ) {
78
71
expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm-foo- can sing' ) ;
79
72
return changeLogEles . count ( ) ;
80
73
} ) . then ( function ( count : number ) {
81
74
// one more for each keystroke
82
75
expect ( count ) . toEqual ( logCount + 5 , 'should add 5 more messages' ) ;
83
76
logCount = count ;
84
- // return powerInputEle.sendKeys('-bar-');
85
- return sendKeys ( powerInputEle , '-bar-' ) ;
77
+ return powerInputEle . sendKeys ( '-bar-' ) ;
86
78
} ) . then ( function ( ) {
87
79
expect ( titleEle . getText ( ) ) . toContain ( 'Windstorm-foo- can sing-bar-' ) ;
88
80
expect ( changeLogEles . count ( ) ) . toEqual ( logCount + 6 , 'should add 6 more messages' ) ;
@@ -102,14 +94,14 @@ describe('Lifecycle hooks', function () {
102
94
103
95
logEles . count ( ) . then ( function ( count : number ) {
104
96
logCount = count ;
105
- return sendKeys ( childViewInputEle , '-test-' ) ;
97
+ return childViewInputEle . sendKeys ( '-test-' ) ;
106
98
} ) . then ( function ( ) {
107
99
expect ( childViewInputEle . getAttribute ( 'value' ) ) . toContain ( '-test-' ) ;
108
100
expect ( commentEle . isPresent ( ) ) . toBe ( true , 'should have comment because >10 chars' ) ;
109
101
expect ( commentEle . getText ( ) ) . toContain ( 'long name' ) ;
110
102
return logEles . count ( ) ;
111
103
} ) . 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' ) ;
113
105
logCount = count ;
114
106
return buttonEle . click ( ) ;
115
107
} ) . then ( function ( ) {
@@ -131,7 +123,7 @@ describe('Lifecycle hooks', function () {
131
123
132
124
logEles . count ( ) . then ( function ( count : number ) {
133
125
logCount = count ;
134
- return sendKeys ( childViewInputEle , '-test-' ) ;
126
+ return childViewInputEle . sendKeys ( '-test-' ) ;
135
127
} ) . then ( function ( ) {
136
128
expect ( childViewInputEle . getAttribute ( 'value' ) ) . toContain ( '-test-' ) ;
137
129
expect ( commentEle . isPresent ( ) ) . toBe ( true , 'should have comment because >10 chars' ) ;
@@ -154,7 +146,7 @@ describe('Lifecycle hooks', function () {
154
146
let logEles = element . all ( by . css ( 'spy-parent h4 ~ div' ) ) ;
155
147
expect ( heroEles . count ( ) ) . toBe ( 2 , 'should have two heroes displayed' ) ;
156
148
expect ( logEles . count ( ) ) . toBe ( 2 , 'should have two log entries' ) ;
157
- sendKeys ( inputEle , '-test-' ) . then ( function ( ) {
149
+ inputEle . sendKeys ( '-test-' ) . then ( function ( ) {
158
150
return addHeroButtonEle . click ( ) ;
159
151
} ) . then ( function ( ) {
160
152
expect ( heroEles . count ( ) ) . toBe ( 3 , 'should have added one hero' ) ;
0 commit comments