@@ -58,8 +58,68 @@ describe('text-expander single word parsing', function() {
58
58
} )
59
59
60
60
describe ( 'text-expander multi word parsing' , function ( ) {
61
- it ( 'does matches with a space between cursor and activation key' , function ( ) {
61
+ it ( 'does not match empty text' , function ( ) {
62
+ const found = query ( '' , ':' , 0 , true )
63
+ assert ( found == null )
64
+ } )
65
+
66
+ it ( 'does not match without activation key' , function ( ) {
67
+ const found = query ( 'cat' , ':' , 3 , true )
68
+ assert ( found == null )
69
+ } )
70
+
71
+ it ( 'matches only activation key' , function ( ) {
72
+ const found = query ( ':' , ':' , 1 , true )
73
+ assert . deepEqual ( found , { text : '' , position : 1 } )
74
+ } )
75
+
76
+ it ( 'matches trailing activation key' , function ( ) {
77
+ const found = query ( 'hi :' , ':' , 4 , true )
78
+ assert . deepEqual ( found , { text : '' , position : 4 } )
79
+ } )
80
+
81
+ it ( 'matches start of text' , function ( ) {
82
+ const found = query ( ':cat' , ':' , 4 , true )
83
+ assert . deepEqual ( found , { text : 'cat' , position : 1 } )
84
+ } )
85
+
86
+ it ( 'matches end of text' , function ( ) {
87
+ const found = query ( 'hi :cat' , ':' , 7 , true )
88
+ assert . deepEqual ( found , { text : 'cat' , position : 4 } )
89
+ } )
90
+
91
+ it ( 'matches middle of text' , function ( ) {
92
+ const found = query ( 'hi :cat bye' , ':' , 7 , true )
93
+ assert . deepEqual ( found , { text : 'cat' , position : 4 } )
94
+ } )
95
+
96
+ it ( 'matches only at word boundary' , function ( ) {
97
+ const found = query ( 'hi:cat' , ':' , 6 , true )
98
+ assert ( found == null )
99
+ } )
100
+
101
+ it ( 'matches last activation key word' , function ( ) {
102
+ const found = query ( 'hi :cat bye :dog' , ':' , 16 , true )
103
+ assert . deepEqual ( found , { text : 'dog' , position : 13 } )
104
+ } )
105
+
106
+ it ( 'matches closest activation key word' , function ( ) {
107
+ const found = query ( 'hi :cat bye :dog' , ':' , 7 , true )
108
+ assert . deepEqual ( found , { text : 'cat' , position : 4 } )
109
+ } )
110
+
111
+ it ( 'matches with a space between cursor and activation key' , function ( ) {
62
112
const found = query ( 'hi :cat bye' , ':' , 11 , true )
63
113
assert . deepEqual ( found , { text : 'cat bye' , position : 4 } )
64
114
} )
115
+
116
+ it ( 'does not match with a dot between cursor and activation key' , function ( ) {
117
+ const found = query ( 'hi :cat. bye' , ':' , 11 , true )
118
+ assert ( found == null )
119
+ } )
120
+
121
+ it ( 'does not match with a space between text and activation key' , function ( ) {
122
+ const found = query ( 'hi : cat bye' , ':' , 7 , true )
123
+ assert ( found == null )
124
+ } )
65
125
} )
0 commit comments