Skip to content

Commit

Permalink
chore: add panic test for extensions without a leading dot
Browse files Browse the repository at this point in the history
  • Loading branch information
Boshen committed Apr 25, 2024
1 parent 2b4c3d0 commit b55b89c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub struct ResolveOptions {
/// If multiple files share the same name but have different extensions,
/// will resolve the one with the extension listed first in the array and skip the rest.
///
/// All extensions must begin with a leading dot.
/// All extensions must have a leading dot.
///
/// Default `[".js", ".json", ".node"]`
pub extensions: Vec<String>,
Expand Down
9 changes: 9 additions & 0 deletions src/tests/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,12 @@ fn multi_dot_extension() {
assert_eq!(resolution, Err(error), "{comment} {request} {resolution:?}");
}
}

#[test]
#[should_panic = "All extensions must start with a leading dot"]
fn without_leading_dot() {
Resolver::new(ResolveOptions {
extensions: vec!["ts".into(), "js".into()],
..ResolveOptions::default()
});
}
4 changes: 3 additions & 1 deletion tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,7 @@ fn options_api() {
.with_main_field("asdf")
.with_fully_specified(true)
.with_prefer_relative(true)
.with_prefer_absolute(true);
.with_prefer_absolute(true)
.with_module("module")
.with_main_file("main");
}

0 comments on commit b55b89c

Please sign in to comment.