diff options
| author | dfireBird <me@dfirebird.dev> | 2023-09-11 17:36:09 +0530 |
|---|---|---|
| committer | dfireBird <me@dfirebird.dev> | 2023-09-11 17:43:53 +0530 |
| commit | df1239bf9246423f1006e4affb38ee504ef3dc79 (patch) | |
| tree | 4f21adf4ae20f8e0aa0b4d118db85a77f67ee581 | |
| parent | d79486529e5f39216f202971c076997486a0b1c5 (diff) | |
| download | rust-df1239bf9246423f1006e4affb38ee504ef3dc79.tar.gz rust-df1239bf9246423f1006e4affb38ee504ef3dc79.zip | |
add tests for insert use with renamed imports
Tested for two cases: 1. Simple Use 2. Complex Use
| -rw-r--r-- | crates/ide-db/src/imports/insert_use/tests.rs | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/crates/ide-db/src/imports/insert_use/tests.rs b/crates/ide-db/src/imports/insert_use/tests.rs index b92e367f7e1..01d2f1970c3 100644 --- a/crates/ide-db/src/imports/insert_use/tests.rs +++ b/crates/ide-db/src/imports/insert_use/tests.rs @@ -993,6 +993,46 @@ use foo::bar::qux; ); } +#[test] +fn insert_with_renamed_import_simple_use() { + check_with_config( + "use self::foo::Foo", + r#" +use self::foo::Foo as _; +"#, + r#" +use self::foo::Foo; +"#, + &InsertUseConfig { + granularity: ImportGranularity::Crate, + prefix_kind: hir::PrefixKind::BySelf, + enforce_granularity: true, + group: true, + skip_glob_imports: true, + }, + ); +} + +#[test] +fn insert_with_renamed_import_complex_use() { + check_with_config( + "use self::foo::Foo;", + r#" +use self::foo::{self, Foo as _, Bar}; +"#, + r#" +use self::foo::{self, Foo, Bar}; +"#, + &InsertUseConfig { + granularity: ImportGranularity::Crate, + prefix_kind: hir::PrefixKind::BySelf, + enforce_granularity: true, + group: true, + skip_glob_imports: true, + }, + ); +} + fn check_with_config( path: &str, ra_fixture_before: &str, |
