@@ -97,24 +97,25 @@ impl<'a> DocumentContext<'a> {
97
97
#[ cfg( test) ]
98
98
mod tests {
99
99
use super :: * ;
100
+ use crate :: fixtures:: point_from_cursor;
100
101
use crate :: treesitter:: node_text;
101
102
use crate :: treesitter:: NodeType ;
102
103
use crate :: treesitter:: NodeTypeExt ;
103
104
104
105
#[ test]
105
106
fn test_document_context_start_of_document ( ) {
106
- let point = Point { row : 0 , column : 0 } ;
107
-
108
107
// Empty document
109
- let document = Document :: new ( "" , None ) ;
108
+ let ( text, point) = point_from_cursor ( "@" ) ;
109
+ let document = Document :: new ( text. as_str ( ) , None ) ;
110
110
let context = DocumentContext :: new ( & document, point, None ) ;
111
111
assert_eq ! (
112
112
node_text( & context. node, & context. document. contents) . unwrap( ) ,
113
113
""
114
114
) ;
115
115
116
116
// Start of document with text
117
- let document = Document :: new ( "1 + 1" , None ) ;
117
+ let ( text, point) = point_from_cursor ( "@1 + 1" ) ;
118
+ let document = Document :: new ( text. as_str ( ) , None ) ;
118
119
let context = DocumentContext :: new ( & document, point, None ) ;
119
120
assert_eq ! (
120
121
node_text( & context. node, & context. document. contents) . unwrap( ) ,
@@ -124,8 +125,9 @@ mod tests {
124
125
125
126
#[ test]
126
127
fn test_document_context_cursor_on_empty_line ( ) {
127
- let document = Document :: new ( "toupper(letters)\n " , None ) ;
128
- let point = Point { row : 1 , column : 0 } ; // as if we're about to type on the second line
128
+ // as if we're about to type on the second line
129
+ let ( text, point) = point_from_cursor ( "toupper(letters)\n @" ) ;
130
+ let document = Document :: new ( text. as_str ( ) , None ) ;
129
131
let context = DocumentContext :: new ( & document, point, None ) ;
130
132
131
133
assert_eq ! ( context. node. node_type( ) , NodeType :: Program ) ;
0 commit comments