@@ -126,7 +126,7 @@ module.exports = {
126126 // editing triggered by enter
127127 browser
128128 . dblClick ( '.todo label' )
129- enter ( '.todo:nth-child(1) .edit' , 'edited again!' )
129+ . enterValue ( '.todo:nth-child(1) .edit' , 'edited again!' )
130130 . assert . count ( '.todo.editing' , 0 )
131131 . assert . containsText ( '.todo:nth-child(1) label' , 'edited again!' )
132132
@@ -135,14 +135,14 @@ module.exports = {
135135 . dblClick ( '.todo label' )
136136 . clearValue ( '.todo:nth-child(1) .edit' )
137137 . setValue ( '.todo:nth-child(1) .edit' , 'edited!' )
138- triggerKeyup ( '.todo:nth-child(1) .edit' , 27 )
138+ . trigger ( '.todo:nth-child(1) .edit' , 'keyup ', 27 )
139139 . assert . count ( '.todo.editing' , 0 )
140140 . assert . containsText ( '.todo:nth-child(1) label' , 'edited again!' )
141141
142142 // empty value should remove
143143 browser
144144 . dblClick ( '.todo label' )
145- enter ( '.todo:nth-child(1) .edit' , ' ' )
145+ . enterValue ( '.todo:nth-child(1) .edit' , ' ' )
146146 . assert . count ( '.todo' , 3 )
147147
148148 // toggle all
@@ -154,23 +154,7 @@ module.exports = {
154154 . end ( )
155155
156156 function createNewItem ( text ) {
157- return enter ( '.new-todo' , text )
158- }
159-
160- function enter ( selector , text ) {
161- browser
162- . clearValue ( selector )
163- . setValue ( selector , text )
164- return triggerKeyup ( selector , 13 )
165- }
166-
167- function triggerKeyup ( selector , code ) {
168- return browser . execute ( function ( selector , code ) {
169- var e = document . createEvent ( 'HTMLEvents' )
170- e . initEvent ( 'keyup' , true , true )
171- e . keyCode = code
172- document . querySelector ( selector ) . dispatchEvent ( e )
173- } , [ selector , code ] )
157+ return browser . enterValue ( '.new-todo' , text )
174158 }
175159
176160 function removeItemAt ( n ) {
0 commit comments