Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 84e1314

Browse files
committed
add more tests for normalize import assist
1 parent fc00602 commit 84e1314

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

crates/ide-assists/src/handlers/normalize_import.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,59 @@ mod tests {
147147
);
148148
}
149149

150+
#[test]
151+
fn test_merge_self() {
152+
check_assist_variations!("std::{fmt, fmt::Display}", "std::fmt::{self, Display}");
153+
}
154+
155+
#[test]
156+
fn test_merge_nested() {
157+
check_assist_variations!("std::{fmt::Debug, fmt::Display}", "std::fmt::{Debug, Display}");
158+
}
159+
160+
#[test]
161+
fn test_merge_nested2() {
162+
check_assist_variations!("std::{fmt::Debug, fmt::Display}", "std::fmt::{Debug, Display}");
163+
}
164+
165+
#[test]
166+
fn test_merge_self_with_nested_self_item() {
167+
check_assist_variations!(
168+
"std::{fmt::{self, Debug}, fmt::{Write, Display}}",
169+
"std::fmt::{self, Debug, Display, Write}"
170+
);
171+
}
172+
173+
#[test]
174+
fn works_with_trailing_comma() {
175+
check_assist(
176+
normalize_import,
177+
r"
178+
use $0{
179+
foo::bar,
180+
foo::baz,
181+
};
182+
",
183+
r"
184+
use foo::{bar, baz};
185+
",
186+
);
187+
check_assist_import_one(
188+
normalize_import,
189+
r"
190+
use $0{
191+
foo::bar,
192+
foo::baz,
193+
};
194+
",
195+
r"
196+
use {
197+
foo::{bar, baz},
198+
};
199+
",
200+
);
201+
}
202+
150203
#[test]
151204
fn not_applicable_to_normalized_import() {
152205
check_assist_not_applicable_variations!("foo::bar");

0 commit comments

Comments
 (0)