@@ -166,16 +166,28 @@ fn is_trailing_comma(left: SyntaxKind, right: SyntaxKind) -> bool {
166166
167167#[ cfg( test) ]
168168mod tests {
169- use crate :: test_utils:: { assert_eq_text, check_action, extract_range} ;
169+ use ra_syntax:: SourceFile ;
170+ use test_utils:: { add_cursor, assert_eq_text, extract_offset, extract_range} ;
170171
171172 use super :: * ;
172173
173174 fn check_join_lines ( before : & str , after : & str ) {
174- check_action ( before, after, |file, offset| {
175- let range = TextRange :: empty ( offset) ;
176- let res = join_lines ( file, range) ;
177- Some ( res)
178- } )
175+ let ( before_cursor_pos, before) = extract_offset ( before) ;
176+ let file = SourceFile :: parse ( & before) . ok ( ) . unwrap ( ) ;
177+
178+ let range = TextRange :: empty ( before_cursor_pos) ;
179+ let result = join_lines ( & file, range) ;
180+
181+ let actual = {
182+ let mut actual = before. to_string ( ) ;
183+ result. apply ( & mut actual) ;
184+ actual
185+ } ;
186+ let actual_cursor_pos = result
187+ . apply_to_offset ( before_cursor_pos)
188+ . expect ( "cursor position is affected by the edit" ) ;
189+ let actual = add_cursor ( & actual, actual_cursor_pos) ;
190+ assert_eq_text ! ( after, & actual) ;
179191 }
180192
181193 #[ test]
0 commit comments