Skip to content
This repository was archived by the owner on Apr 6, 2018. It is now read-only.

Commit 28ad1a7

Browse files
committed
add tests for text objects expanding selection
1 parent ced0c88 commit 28ad1a7

File tree

1 file changed

+228
-0
lines changed

1 file changed

+228
-0
lines changed

spec/text-objects-spec.coffee

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ describe "TextObjects", ->
5252

5353
expect(editor.getSelectedScreenRange()).toEqual [[0, 6], [0, 11]]
5454

55+
it "expands an existing selection in visual mode", ->
56+
keydown('v')
57+
keydown('l')
58+
keydown('l')
59+
keydown('l')
60+
keydown('i')
61+
keydown('w')
62+
63+
expect(editor.getSelectedScreenRange()).toEqual [[0, 9], [0, 17]]
64+
5565
it "works with multiple cursors", ->
5666
editor.addCursorAtBufferPosition([0, 1])
5767
keydown("v")
@@ -85,6 +95,16 @@ describe "TextObjects", ->
8595

8696
expect(editor.getSelectedScreenRange()).toEqual [[0, 6], [0, 11]]
8797

98+
it "expands an existing selection in visual mode", ->
99+
keydown('v')
100+
keydown('l')
101+
keydown('l')
102+
keydown('l')
103+
keydown('i')
104+
keydown('W', shift: true)
105+
106+
expect(editor.getSelectedScreenRange()).toEqual [[0, 9], [0, 17]]
107+
88108
describe "the 'i(' text object", ->
89109
beforeEach ->
90110
editor.setText("( something in here and in (here) )")
@@ -123,6 +143,18 @@ describe "TextObjects", ->
123143
[[0, 13], [0, 20]]
124144
]
125145

146+
it "expands an existing selection in visual mode", ->
147+
editor.setCursorScreenPosition([0, 25])
148+
keydown('v')
149+
keydown('l')
150+
keydown('l')
151+
keydown('l')
152+
keydown('l')
153+
keydown('i')
154+
keydown('(')
155+
156+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 32]]
157+
126158
describe "the 'i{' text object", ->
127159
beforeEach ->
128160
editor.setText("{ something in here and in {here} }")
@@ -147,6 +179,18 @@ describe "TextObjects", ->
147179
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
148180
expect(editorElement.classList.contains('normal-mode')).toBe(true)
149181

182+
it "expands an existing selection in visual mode", ->
183+
editor.setCursorScreenPosition([0, 25])
184+
keydown('v')
185+
keydown('l')
186+
keydown('l')
187+
keydown('l')
188+
keydown('l')
189+
keydown('i')
190+
keydown('{')
191+
192+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 32]]
193+
150194
describe "the 'i<' text object", ->
151195
beforeEach ->
152196
editor.setText("< something in here and in <here> >")
@@ -171,6 +215,18 @@ describe "TextObjects", ->
171215
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
172216
expect(editorElement.classList.contains('normal-mode')).toBe(true)
173217

218+
it "expands an existing selection in visual mode", ->
219+
editor.setCursorScreenPosition([0, 25])
220+
keydown('v')
221+
keydown('l')
222+
keydown('l')
223+
keydown('l')
224+
keydown('l')
225+
keydown('i')
226+
keydown('<')
227+
228+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 32]]
229+
174230
describe "the 'it' text object", ->
175231
beforeEach ->
176232
editor.setText("<something>here</something><again>")
@@ -195,6 +251,16 @@ describe "TextObjects", ->
195251
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
196252
expect(editorElement.classList.contains('normal-mode')).toBe(true)
197253

254+
it "expands an existing selection in visual mode", ->
255+
editor.setCursorScreenPosition([0, 7])
256+
keydown('v')
257+
keydown('6')
258+
keydown('l')
259+
keydown('i')
260+
keydown('t')
261+
262+
expect(editor.getSelectedScreenRange()).toEqual [[0, 7], [0, 15]]
263+
198264
describe "the 'ip' text object", ->
199265
beforeEach ->
200266
editor.setText("\nParagraph-1\nParagraph-1\nParagraph-1\n\n")
@@ -238,6 +304,22 @@ describe "TextObjects", ->
238304

239305
expect(editor.getSelectedScreenRange()).toEqual [[0, 0], [3, 0]]
240306

307+
it "expands an existing selection in visual mode", ->
308+
editor.setText("\nParagraph-1\nParagraph-1\nParagraph-1\n\n\nParagraph-2\nParagraph-2\nParagraph-2\n")
309+
editor.setCursorBufferPosition([2, 2])
310+
311+
keydown('v')
312+
keydown('i')
313+
keydown('p')
314+
315+
keydown('j')
316+
keydown('j')
317+
keydown('j')
318+
keydown('i')
319+
keydown('p')
320+
321+
expect(editor.getSelectedScreenRange()).toEqual [[1, 0], [9, 0]]
322+
241323
describe "the 'ap' text object", ->
242324
beforeEach ->
243325
editor.setText("text\n\nParagraph-1\nParagraph-1\nParagraph-1\n\n\nmoretext")
@@ -285,6 +367,22 @@ describe "TextObjects", ->
285367

286368
expect(editor.getSelectedScreenRange()).toEqual [[1, 0], [7, 0]]
287369

370+
it "expands an existing selection in visual mode", ->
371+
editor.setText("text\n\n\n\nparagraph-1\nparagraph-1\nparagraph-1\n\n\n\nparagraph-2\nparagraph-2\nparagraph-2\n\n\nmoretext")
372+
editor.setCursorBufferPosition([5, 0])
373+
374+
keydown('v')
375+
keydown('a')
376+
keydown('p')
377+
378+
keydown('j')
379+
keydown('j')
380+
keydown('j')
381+
keydown('i')
382+
keydown('p')
383+
384+
expect(editor.getSelectedScreenRange()).toEqual [[4, 0], [13, 0]]
385+
288386
describe "the 'i[' text object", ->
289387
beforeEach ->
290388
editor.setText("[ something in here and in [here] ]")
@@ -309,6 +407,18 @@ describe "TextObjects", ->
309407
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
310408
expect(editorElement.classList.contains('normal-mode')).toBe(true)
311409

410+
it "expands an existing selection in visual mode", ->
411+
editor.setCursorScreenPosition([0, 25])
412+
keydown('v')
413+
keydown('l')
414+
keydown('l')
415+
keydown('l')
416+
keydown('l')
417+
keydown('i')
418+
keydown('[')
419+
420+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 32]]
421+
312422
describe "the 'i\'' text object", ->
313423
beforeEach ->
314424
editor.setText("' something in here and in 'here' ' and over here")
@@ -343,6 +453,18 @@ describe "TextObjects", ->
343453
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
344454
expect(editorElement.classList.contains('normal-mode')).toBe(true)
345455

456+
it "expands an existing selection in visual mode", ->
457+
editor.setCursorScreenPosition([0, 25])
458+
keydown('v')
459+
keydown('l')
460+
keydown('l')
461+
keydown('l')
462+
keydown('l')
463+
keydown('i')
464+
keydown('\'')
465+
466+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 34]]
467+
346468
describe "the 'i\"' text object", ->
347469
beforeEach ->
348470
editor.setText("\" something in here and in \"here\" \" and over here")
@@ -376,6 +498,18 @@ describe "TextObjects", ->
376498
expect(editor.getCursorScreenPosition()).toEqual [0, 39]
377499
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
378500

501+
it "expands an existing selection in visual mode", ->
502+
editor.setCursorScreenPosition([0, 25])
503+
keydown('v')
504+
keydown('l')
505+
keydown('l')
506+
keydown('l')
507+
keydown('l')
508+
keydown('i')
509+
keydown('"')
510+
511+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 34]]
512+
379513
describe "the 'aw' text object", ->
380514
beforeEach ->
381515
editor.setText("12345 abcde ABCDE")
@@ -399,6 +533,17 @@ describe "TextObjects", ->
399533

400534
expect(editor.getSelectedScreenRange()).toEqual [[0, 6], [0, 12]]
401535

536+
it "expands an existing selection in visual mode", ->
537+
editor.setCursorScreenPosition([0, 2])
538+
keydown('v')
539+
keydown('l')
540+
keydown('l')
541+
keydown('l')
542+
keydown('a')
543+
keydown('w')
544+
545+
expect(editor.getSelectedScreenRange()).toEqual [[0, 2], [0, 12]]
546+
402547
it "doesn't span newlines", ->
403548
editor.setText("12345\nabcde ABCDE")
404549
editor.setCursorBufferPosition([0, 3])
@@ -442,6 +587,17 @@ describe "TextObjects", ->
442587

443588
expect(editor.getSelectedScreenRange()).toEqual [[0, 6], [0, 12]]
444589

590+
it "expands an existing selection in visual mode", ->
591+
editor.setCursorScreenPosition([0, 2])
592+
keydown('v')
593+
keydown('l')
594+
keydown('l')
595+
keydown('l')
596+
keydown('a')
597+
keydown('W', shift: true)
598+
599+
expect(editor.getSelectedScreenRange()).toEqual [[0, 2], [0, 12]]
600+
445601
it "doesn't span newlines", ->
446602
editor.setText("12(45\nab'de ABCDE")
447603
editor.setCursorBufferPosition([0, 4])
@@ -476,6 +632,18 @@ describe "TextObjects", ->
476632
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
477633
expect(editorElement.classList.contains('normal-mode')).toBe(true)
478634

635+
it "expands an existing selection in visual mode", ->
636+
editor.setCursorScreenPosition([0, 25])
637+
keydown('v')
638+
keydown('l')
639+
keydown('l')
640+
keydown('l')
641+
keydown('l')
642+
keydown('a')
643+
keydown('(')
644+
645+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 33]]
646+
479647
describe "the 'a{' text object", ->
480648
beforeEach ->
481649
editor.setText("{ something in here and in {here} }")
@@ -500,6 +668,18 @@ describe "TextObjects", ->
500668
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
501669
expect(editorElement.classList.contains('normal-mode')).toBe(true)
502670

671+
it "expands an existing selection in visual mode", ->
672+
editor.setCursorScreenPosition([0, 25])
673+
keydown('v')
674+
keydown('l')
675+
keydown('l')
676+
keydown('l')
677+
keydown('l')
678+
keydown('a')
679+
keydown('{')
680+
681+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 33]]
682+
503683
describe "the 'a<' text object", ->
504684
beforeEach ->
505685
editor.setText("< something in here and in <here> >")
@@ -524,6 +704,18 @@ describe "TextObjects", ->
524704
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
525705
expect(editorElement.classList.contains('normal-mode')).toBe(true)
526706

707+
it "expands an existing selection in visual mode", ->
708+
editor.setCursorScreenPosition([0, 25])
709+
keydown('v')
710+
keydown('l')
711+
keydown('l')
712+
keydown('l')
713+
keydown('l')
714+
keydown('a')
715+
keydown('<')
716+
717+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 33]]
718+
527719
describe "the 'a[' text object", ->
528720
beforeEach ->
529721
editor.setText("[ something in here and in [here] ]")
@@ -548,6 +740,18 @@ describe "TextObjects", ->
548740
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
549741
expect(editorElement.classList.contains('normal-mode')).toBe(true)
550742

743+
it "expands an existing selection in visual mode", ->
744+
editor.setCursorScreenPosition([0, 25])
745+
keydown('v')
746+
keydown('l')
747+
keydown('l')
748+
keydown('l')
749+
keydown('l')
750+
keydown('a')
751+
keydown('[')
752+
753+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 33]]
754+
551755
describe "the 'a\'' text object", ->
552756
beforeEach ->
553757
editor.setText("' something in here and in 'here' '")
@@ -572,6 +776,18 @@ describe "TextObjects", ->
572776
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
573777
expect(editorElement.classList.contains('normal-mode')).toBe(true)
574778

779+
it "expands an existing selection in visual mode", ->
780+
editor.setCursorScreenPosition([0, 25])
781+
keydown('v')
782+
keydown('l')
783+
keydown('l')
784+
keydown('l')
785+
keydown('l')
786+
keydown('a')
787+
keydown('\'')
788+
789+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 35]]
790+
575791
describe "the 'a\"' text object", ->
576792
beforeEach ->
577793
editor.setText("\" something in here and in \"here\" \"")
@@ -595,3 +811,15 @@ describe "TextObjects", ->
595811
expect(editor.getCursorScreenPosition()).toEqual [0, 31]
596812
expect(editorElement.classList.contains('operator-pending-mode')).toBe(false)
597813
expect(editorElement.classList.contains('normal-mode')).toBe(true)
814+
815+
it "expands an existing selection in visual mode", ->
816+
editor.setCursorScreenPosition([0, 25])
817+
keydown('v')
818+
keydown('l')
819+
keydown('l')
820+
keydown('l')
821+
keydown('l')
822+
keydown('a')
823+
keydown('"')
824+
825+
expect(editor.getSelectedScreenRange()).toEqual [[0, 25], [0, 35]]

0 commit comments

Comments
 (0)