Skip to content

Commit df1239b

Browse files
committed
add tests for insert use with renamed imports
Tested for two cases: 1. Simple Use 2. Complex Use
1 parent d794865 commit df1239b

File tree

1 file changed

+40
-0
lines changed
  • crates/ide-db/src/imports/insert_use

1 file changed

+40
-0
lines changed

crates/ide-db/src/imports/insert_use/tests.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,46 @@ use foo::bar::qux;
993993
);
994994
}
995995

996+
#[test]
997+
fn insert_with_renamed_import_simple_use() {
998+
check_with_config(
999+
"use self::foo::Foo",
1000+
r#"
1001+
use self::foo::Foo as _;
1002+
"#,
1003+
r#"
1004+
use self::foo::Foo;
1005+
"#,
1006+
&InsertUseConfig {
1007+
granularity: ImportGranularity::Crate,
1008+
prefix_kind: hir::PrefixKind::BySelf,
1009+
enforce_granularity: true,
1010+
group: true,
1011+
skip_glob_imports: true,
1012+
},
1013+
);
1014+
}
1015+
1016+
#[test]
1017+
fn insert_with_renamed_import_complex_use() {
1018+
check_with_config(
1019+
"use self::foo::Foo;",
1020+
r#"
1021+
use self::foo::{self, Foo as _, Bar};
1022+
"#,
1023+
r#"
1024+
use self::foo::{self, Foo, Bar};
1025+
"#,
1026+
&InsertUseConfig {
1027+
granularity: ImportGranularity::Crate,
1028+
prefix_kind: hir::PrefixKind::BySelf,
1029+
enforce_granularity: true,
1030+
group: true,
1031+
skip_glob_imports: true,
1032+
},
1033+
);
1034+
}
1035+
9961036
fn check_with_config(
9971037
path: &str,
9981038
ra_fixture_before: &str,

0 commit comments

Comments
 (0)