@@ -68,7 +68,7 @@ void main() {
68
68
///
69
69
/// For example, "~@chris^" means the text is "@chris", the selection is
70
70
/// collapsed at index 6, and we expect the syntax to start at index 0.
71
- void doTest (String markedText, MentionAutocompleteQuery ? expectedQuery) {
71
+ void doTest (String markedText, ComposeAutocompleteQuery ? expectedQuery) {
72
72
final description = expectedQuery != null
73
73
? 'in ${jsonEncode (markedText )}, query ${jsonEncode (expectedQuery .raw )}'
74
74
: 'no query in ${jsonEncode (markedText )}' ;
@@ -87,8 +87,8 @@ void main() {
87
87
});
88
88
}
89
89
90
- MentionAutocompleteQuery queryOf (String raw) => MentionAutocompleteQuery (raw, silent: false );
91
- MentionAutocompleteQuery silentQueryOf (String raw) => MentionAutocompleteQuery (raw, silent: true );
90
+ MentionAutocompleteQuery mention (String raw) => MentionAutocompleteQuery (raw, silent: false );
91
+ MentionAutocompleteQuery silentMention (String raw) => MentionAutocompleteQuery (raw, silent: true );
92
92
93
93
doTest ('' , null );
94
94
doTest ('^' , null );
@@ -125,48 +125,48 @@ void main() {
125
125
126
126
doTest ('`@chris^' , null ); doTest ('`@_chris^' , null );
127
127
128
- doTest ('~@^_' , queryOf ('' )); // Odd/unlikely, but should not crash
128
+ doTest ('~@^_' , mention ('' )); // Odd/unlikely, but should not crash
129
129
130
- doTest ('~@__^' , silentQueryOf ('_' ));
130
+ doTest ('~@__^' , silentMention ('_' ));
131
131
132
- doTest ('~@^abc^' , queryOf ('abc' )); doTest ('~@_^abc^' , silentQueryOf ('abc' ));
133
- doTest ('~@a^bc^' , queryOf ('abc' )); doTest ('~@_a^bc^' , silentQueryOf ('abc' ));
134
- doTest ('~@ab^c^' , queryOf ('abc' )); doTest ('~@_ab^c^' , silentQueryOf ('abc' ));
135
- doTest ('~^@^' , queryOf ('' )); doTest ('~^@_^' , silentQueryOf ('' ));
132
+ doTest ('~@^abc^' , mention ('abc' )); doTest ('~@_^abc^' , silentMention ('abc' ));
133
+ doTest ('~@a^bc^' , mention ('abc' )); doTest ('~@_a^bc^' , silentMention ('abc' ));
134
+ doTest ('~@ab^c^' , mention ('abc' )); doTest ('~@_ab^c^' , silentMention ('abc' ));
135
+ doTest ('~^@^' , mention ('' )); doTest ('~^@_^' , silentMention ('' ));
136
136
// but:
137
137
doTest ('^hello @chris^' , null ); doTest ('^hello @_chris^' , null );
138
138
139
-
140
- doTest (
'~@me@^zulip.com^' ,
queryOf (
'[email protected] ' ));
doTest (
'~@_me@^zulip.com^' ,
silentQueryOf (
'[email protected] ' ));
141
- doTest (
'~@me^@zulip.com^' ,
queryOf (
'[email protected] ' ));
doTest (
'~@_me^@zulip.com^' ,
silentQueryOf (
'[email protected] ' ));
142
-
143
-
144
- doTest ('~@abc^' , queryOf ('abc' )); doTest ('~@_abc^' , silentQueryOf ('abc' ));
145
- doTest (' ~@abc^' , queryOf ('abc' )); doTest (' ~@_abc^' , silentQueryOf ('abc' ));
146
- doTest ('(~@abc^' , queryOf ('abc' )); doTest ('(~@_abc^' , silentQueryOf ('abc' ));
147
- doTest ('—~@abc^' , queryOf ('abc' )); doTest ('—~@_abc^' , silentQueryOf ('abc' ));
148
- doTest ('"~@abc^' , queryOf ('abc' )); doTest ('"~@_abc^' , silentQueryOf ('abc' ));
149
- doTest ('“~@abc^' , queryOf ('abc' )); doTest ('“~@_abc^' , silentQueryOf ('abc' ));
150
- doTest ('。~@abc^' , queryOf ('abc' )); doTest ('。~@_abc^' , silentQueryOf ('abc' ));
151
- doTest ('«~@abc^' , queryOf ('abc' )); doTest ('«~@_abc^' , silentQueryOf ('abc' ));
152
-
153
- doTest ('~@ab^c' , queryOf ('ab' )); doTest ('~@_ab^c' , silentQueryOf ('ab' ));
154
- doTest ('~@a^bc' , queryOf ('a' )); doTest ('~@_a^bc' , silentQueryOf ('a' ));
155
- doTest ('~@^abc' , queryOf ('' )); doTest ('~@_^abc' , silentQueryOf ('' ));
156
- doTest ('~@^' , queryOf ('' )); doTest ('~@_^' , silentQueryOf ('' ));
157
-
158
- doTest ('~@abc ^' , queryOf ('abc ' )); doTest ('~@_abc ^' , silentQueryOf ('abc ' ));
159
- doTest ('~@abc^ ^' , queryOf ('abc ' )); doTest ('~@_abc^ ^' , silentQueryOf ('abc ' ));
160
- doTest ('~@ab^c ^' , queryOf ('abc ' )); doTest ('~@_ab^c ^' , silentQueryOf ('abc ' ));
161
- doTest ('~@^abc ^' , queryOf ('abc ' )); doTest ('~@_^abc ^' , silentQueryOf ('abc ' ));
162
-
163
- doTest ('Please ask ~@chris^' , queryOf ('chris' )); doTest ('Please ask ~@_chris^' , silentQueryOf ('chris' ));
164
- doTest ('Please ask ~@chris bobbe^' , queryOf ('chris bobbe' )); doTest ('Please ask ~@_chris bobbe^' , silentQueryOf ('chris bobbe' ));
165
-
166
- doTest ('~@Rodion Romanovich Raskolnikov^' , queryOf ('Rodion Romanovich Raskolnikov' ));
167
- doTest ('~@_Rodion Romanovich Raskolniko^' , silentQueryOf ('Rodion Romanovich Raskolniko' ));
168
- doTest ('~@Родион Романович Раскольников^' , queryOf ('Родион Романович Раскольников' ));
169
- doTest ('~@_Родион Романович Раскольнико^' , silentQueryOf ('Родион Романович Раскольнико' ));
139
+
140
+ doTest (
'~@me@^zulip.com^' ,
mention (
'[email protected] ' ));
doTest (
'~@_me@^zulip.com^' ,
silentMention (
'[email protected] ' ));
141
+ doTest (
'~@me^@zulip.com^' ,
mention (
'[email protected] ' ));
doTest (
'~@_me^@zulip.com^' ,
silentMention (
'[email protected] ' ));
142
+
143
+
144
+ doTest ('~@abc^' , mention ('abc' )); doTest ('~@_abc^' , silentMention ('abc' ));
145
+ doTest (' ~@abc^' , mention ('abc' )); doTest (' ~@_abc^' , silentMention ('abc' ));
146
+ doTest ('(~@abc^' , mention ('abc' )); doTest ('(~@_abc^' , silentMention ('abc' ));
147
+ doTest ('—~@abc^' , mention ('abc' )); doTest ('—~@_abc^' , silentMention ('abc' ));
148
+ doTest ('"~@abc^' , mention ('abc' )); doTest ('"~@_abc^' , silentMention ('abc' ));
149
+ doTest ('“~@abc^' , mention ('abc' )); doTest ('“~@_abc^' , silentMention ('abc' ));
150
+ doTest ('。~@abc^' , mention ('abc' )); doTest ('。~@_abc^' , silentMention ('abc' ));
151
+ doTest ('«~@abc^' , mention ('abc' )); doTest ('«~@_abc^' , silentMention ('abc' ));
152
+
153
+ doTest ('~@ab^c' , mention ('ab' )); doTest ('~@_ab^c' , silentMention ('ab' ));
154
+ doTest ('~@a^bc' , mention ('a' )); doTest ('~@_a^bc' , silentMention ('a' ));
155
+ doTest ('~@^abc' , mention ('' )); doTest ('~@_^abc' , silentMention ('' ));
156
+ doTest ('~@^' , mention ('' )); doTest ('~@_^' , silentMention ('' ));
157
+
158
+ doTest ('~@abc ^' , mention ('abc ' )); doTest ('~@_abc ^' , silentMention ('abc ' ));
159
+ doTest ('~@abc^ ^' , mention ('abc ' )); doTest ('~@_abc^ ^' , silentMention ('abc ' ));
160
+ doTest ('~@ab^c ^' , mention ('abc ' )); doTest ('~@_ab^c ^' , silentMention ('abc ' ));
161
+ doTest ('~@^abc ^' , mention ('abc ' )); doTest ('~@_^abc ^' , silentMention ('abc ' ));
162
+
163
+ doTest ('Please ask ~@chris^' , mention ('chris' )); doTest ('Please ask ~@_chris^' , silentMention ('chris' ));
164
+ doTest ('Please ask ~@chris bobbe^' , mention ('chris bobbe' )); doTest ('Please ask ~@_chris bobbe^' , silentMention ('chris bobbe' ));
165
+
166
+ doTest ('~@Rodion Romanovich Raskolnikov^' , mention ('Rodion Romanovich Raskolnikov' ));
167
+ doTest ('~@_Rodion Romanovich Raskolniko^' , silentMention ('Rodion Romanovich Raskolniko' ));
168
+ doTest ('~@Родион Романович Раскольников^' , mention ('Родион Романович Раскольников' ));
169
+ doTest ('~@_Родион Романович Раскольнико^' , silentMention ('Родион Романович Раскольнико' ));
170
170
doTest ('If @chris is around, please ask him.^' , null ); // @ sign is too far away from cursor
171
171
doTest ('If @_chris is around, please ask him.^' , null ); // @ sign is too far away from cursor
172
172
});
0 commit comments