@@ -4,72 +4,70 @@ import 'package:flutter_code_editor/src/code_modifiers/insertion.dart';
4
4
import 'package:flutter_test/flutter_test.dart' ;
5
5
6
6
void main () {
7
- test ( 'inserts at the start of string correctly ' , () {
7
+ group ( 'InsertionCodeModifier ' , () {
8
8
const modifier = InsertionCodeModifier (openChar: '1' , closeString: '23' );
9
- const text = 'Hello World' ;
10
- final selection = TextSelection .fromPosition (const TextPosition (offset: 0 ));
11
9
const editorParams = EditorParams ();
12
10
13
- final result = modifier.updateString (text, selection, editorParams);
11
+ test ('inserts at the start of string correctly' , () {
12
+ const text = 'Hello World' ;
13
+ final selection =
14
+ TextSelection .fromPosition (const TextPosition (offset: 0 ));
14
15
15
- expect (result! .text, '123Hello World' );
16
- expect (result.selection.baseOffset, 1 );
17
- expect (result.selection.extentOffset, 1 );
18
- });
16
+ final result = modifier.updateString (text, selection, editorParams);
19
17
20
- test ('inserts in the middle of string correctly' , () {
21
- const modifier = InsertionCodeModifier (openChar: '1' , closeString: '23' );
22
- const text = 'Hello World' ;
23
- final selection = TextSelection .fromPosition (const TextPosition (offset: 5 ));
24
- const editorParams = EditorParams ();
18
+ expect (result! .text, '123Hello World' );
19
+ expect (result.selection.baseOffset, 1 );
20
+ expect (result.selection.extentOffset, 1 );
21
+ });
25
22
26
- final result = modifier.updateString (text, selection, editorParams);
23
+ test ('inserts in the middle of string correctly' , () {
24
+ const text = 'Hello World' ;
25
+ final selection =
26
+ TextSelection .fromPosition (const TextPosition (offset: 5 ));
27
27
28
- expect (result! .text, 'Hello123 World' );
29
- expect (result.selection.baseOffset, 6 );
30
- expect (result.selection.extentOffset, 6 );
31
- });
28
+ final result = modifier.updateString (text, selection, editorParams);
32
29
33
- test ('inserts at the end of string correctly' , () {
34
- const modifier = InsertionCodeModifier (openChar: '1' , closeString: '23' );
35
- const text = 'Hello World' ;
36
- final selection =
37
- TextSelection .fromPosition (const TextPosition (offset: text.length));
38
- const editorParams = EditorParams ();
30
+ expect (result! .text, 'Hello123 World' );
31
+ expect (result.selection.baseOffset, 6 );
32
+ expect (result.selection.extentOffset, 6 );
33
+ });
39
34
40
- final result = modifier.updateString (text, selection, editorParams);
35
+ test ('inserts at the end of string correctly' , () {
36
+ const text = 'Hello World' ;
37
+ final selection =
38
+ TextSelection .fromPosition (const TextPosition (offset: text.length));
41
39
42
- expect (result! .text, 'Hello World123' );
43
- expect (result.selection.baseOffset, text.length + 1 );
44
- expect (result.selection.extentOffset, text.length + 1 );
45
- });
40
+ final result = modifier.updateString (text, selection, editorParams);
46
41
47
- test ('inserts in the middle of string with selection correctly' , () {
48
- const modifier = InsertionCodeModifier (openChar: '1' , closeString: '23' );
49
- const text = 'Hello World' ;
50
- const selection = TextSelection (
51
- baseOffset: 5 ,
52
- extentOffset: 7 ,
53
- );
54
- const editorParams = EditorParams ();
42
+ expect (result! .text, 'Hello World123' );
43
+ expect (result.selection.baseOffset, text.length + 1 );
44
+ expect (result.selection.extentOffset, text.length + 1 );
45
+ });
55
46
56
- final result = modifier.updateString (text, selection, editorParams);
47
+ test ('inserts in the middle of string with selection correctly' , () {
48
+ const text = 'Hello World' ;
49
+ const selection = TextSelection (
50
+ baseOffset: 5 ,
51
+ extentOffset: 7 ,
52
+ );
57
53
58
- expect (result! .text, 'Hello123orld' );
59
- expect (result.selection.baseOffset, 6 );
60
- expect (result.selection.extentOffset, 6 );
61
- });
54
+ final result = modifier.updateString (text, selection, editorParams);
62
55
63
- test ('inserts at empty string correctly' , () {
64
- const modifier = InsertionCodeModifier (openChar: '1' , closeString: '23' );
65
- const text = '' ;
66
- final selection = TextSelection .fromPosition (const TextPosition (offset: 0 ));
67
- const editorParams = EditorParams ();
56
+ expect (result! .text, 'Hello123orld' );
57
+ expect (result.selection.baseOffset, 6 );
58
+ expect (result.selection.extentOffset, 6 );
59
+ });
60
+
61
+ test ('inserts at empty string correctly' , () {
62
+ const text = '' ;
63
+ final selection =
64
+ TextSelection .fromPosition (const TextPosition (offset: 0 ));
68
65
69
- final result = modifier.updateString (text, selection, editorParams);
66
+ final result = modifier.updateString (text, selection, editorParams);
70
67
71
- expect (result! .text, '123' );
72
- expect (result.selection.baseOffset, 1 );
73
- expect (result.selection.extentOffset, 1 );
68
+ expect (result! .text, '123' );
69
+ expect (result.selection.baseOffset, 1 );
70
+ expect (result.selection.extentOffset, 1 );
71
+ });
74
72
});
75
73
}
0 commit comments