@@ -72,6 +72,12 @@ describe("React Textarea Autocomplete", () => {
72
72
. should ( "have.value" , "This is test🙄" ) ;
73
73
} ) ;
74
74
75
+ it ( "should respect already written tokens" , ( ) => {
76
+ cy . get ( ".rta__textarea" )
77
+ . type ( "This is test -f{enter} and -s{downarrow}{enter}" )
78
+ . should ( "have.value" , "This is test -first and -second" ) ;
79
+ } ) ;
80
+
75
81
it ( "special character like [, ( should be also possible to use as trigger char" , ( ) => {
76
82
cy . get ( ".rta__textarea" )
77
83
. type ( "This is test [{enter}" )
@@ -99,7 +105,7 @@ describe("React Textarea Autocomplete", () => {
99
105
. then ( ( ) => {
100
106
const endLeft = Cypress . $ ( ".rta__autocomplete" ) . css ( "left" ) ;
101
107
cy . get ( ".rta__autocomplete" ) . should ( "to.have.css" , {
102
- left : startLeft
108
+ left : startLeft ,
103
109
} ) ;
104
110
105
111
expect ( startLeft ) . to . be . equal ( endLeft ) ;
@@ -136,10 +142,10 @@ describe("React Textarea Autocomplete", () => {
136
142
137
143
it ( "onItemHighlighted should return correct item and trigger" , ( ) => {
138
144
cy . get ( ".rta__textarea" ) . type ( ":ro{uparrow}{uparrow}" ) ;
139
- cy . window ( ) . then ( async win => {
145
+ cy . window ( ) . then ( async ( win ) => {
140
146
const shouldSelectItem = {
141
147
currentTrigger : ":" ,
142
- item : { name : "rofl" , char : "🤣" }
148
+ item : { name : "rofl" , char : "🤣" } ,
143
149
} ;
144
150
145
151
expect ( win . __lastHighlightedItem ) . to . deep . equal ( shouldSelectItem ) ;
@@ -148,21 +154,17 @@ describe("React Textarea Autocomplete", () => {
148
154
149
155
it ( "onItemSelected should return correct item and trigger" , ( ) => {
150
156
cy . get ( ".rta__textarea" ) . type ( ":ro{uparrow}{uparrow}{enter}" ) ;
151
- cy . window ( ) . then ( async win => {
157
+ cy . window ( ) . then ( async ( win ) => {
152
158
const shouldSelectItem = {
153
159
currentTrigger : ":" ,
154
- item : { name : "rofl" , char : "🤣" }
160
+ item : { name : "rofl" , char : "🤣" } ,
155
161
} ;
156
162
157
163
expect ( win . __lastSelectedItem ) . to . deep . equal ( shouldSelectItem ) ;
158
164
} ) ;
159
165
} ) ;
160
166
161
167
it ( "should have place caret before outputted word" , ( ) => {
162
- /**
163
- * This is probably Cypress bug (1.0.2)
164
- * This test needs to be run in headed mode, otherwise fails
165
- */
166
168
cy . get ( '[data-test="caretStart"]' ) . click ( ) ;
167
169
168
170
cy . get ( ".rta__textarea" ) . type ( "This is test :ro{downarrow}{downarrow}" ) ;
@@ -173,10 +175,6 @@ describe("React Textarea Autocomplete", () => {
173
175
} ) ;
174
176
175
177
it ( "should place caret after word" , ( ) => {
176
- /**
177
- * This is probably Cypress bug (1.0.2)
178
- * This test needs to be run in headed mode, otherwise fails
179
- */
180
178
cy . get ( '[data-test="caretEnd"]' ) . click ( ) ;
181
179
182
180
cy . get ( ".rta__textarea" ) . type ( "This is test :ro{downarrow}{downarrow}" ) ;
@@ -187,10 +185,6 @@ describe("React Textarea Autocomplete", () => {
187
185
} ) ;
188
186
189
187
it ( "should caret after word with a space" , ( ) => {
190
- /**
191
- * This is probably Cypress bug (1.0.2)
192
- * This test needs to be run in headed mode, otherwise fails
193
- */
194
188
cy . get ( '[data-test="caretNext"]' ) . click ( ) ;
195
189
196
190
cy . get ( ".rta__textarea" ) . type ( "This is test :ro{downarrow}{downarrow}" ) ;
@@ -266,7 +260,7 @@ describe("React Textarea Autocomplete", () => {
266
260
cy . get ( ".rta__textarea" ) . type (
267
261
`${ repeat ( "{backspace}" , 13 ) } again {downarrow}{enter}` ,
268
262
{
269
- force : true
263
+ force : true ,
270
264
}
271
265
) ;
272
266
cy . get ( ".rta__textarea" ) . should ( "have.value" , "This is test /" ) ;
@@ -366,7 +360,7 @@ describe("React Textarea Autocomplete", () => {
366
360
. get ( "li:nth-child(1)" )
367
361
. click ( ) ;
368
362
cy . get ( ".rta__textarea" ) . type ( `${ repeat ( "\n" , 5 ) } test :a` , {
369
- force : true
363
+ force : true ,
370
364
} ) ;
371
365
cy . get ( ".rta__autocomplete" ) . should (
372
366
"have.class" ,
@@ -395,13 +389,13 @@ describe("React Textarea Autocomplete", () => {
395
389
} ) ;
396
390
397
391
it ( "event is successfully blocked" , ( ) => {
398
- cy . window ( ) . then ( async win => {
392
+ cy . window ( ) . then ( async ( win ) => {
399
393
const spy = cy . spy ( win . console , "log" ) ;
400
394
401
395
await cy
402
396
. get ( ".rta__textarea" )
403
397
. type ( ":ro{uparrow}{uparrow}{enter}" )
404
- . then ( e => {
398
+ . then ( ( e ) => {
405
399
// the last console.log call should not be `pressed "enter"` because that event is blocked because it's happening in autocomplete.
406
400
expect ( spy . lastCall . args ) . to . eql ( [ `pressed "o"` ] ) ;
407
401
} ) ;
0 commit comments