1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

Add test.

This commit is contained in:
David Sherret 2022-08-25 10:21:18 -04:00
parent e92d7add38
commit 7c0bbaada1

View file

@ -378,6 +378,55 @@ mod test {
); );
} }
#[tokio::test]
async fn remote_url_no_path() {
let mut builder = VendorTestBuilder::with_default_setup();
let output = builder
.with_loader(|loader| {
loader
.add(
"/mod.ts",
concat!(
r#"import "https://localhost";"#,
r#"import "https://localhost/subdir/mod.ts";"#,
),
)
.add_with_headers(
"https://localhost",
"import './subdir'; export class Mod1 {}",
&[("content-type", "application/typescript")],
)
.add_with_headers(
"https://localhost/subdir",
"import './subdir/mod.ts'; export class Mod2 {}",
&[("content-type", "application/typescript")],
)
.add("https://localhost/subdir/mod.ts", "export class Mod3 {}");
})
.build()
.await
.unwrap();
assert_eq!(
output.import_map,
Some(json!({
"imports": {
"https://localhost/": "./localhost/",
"https://localhost": "./localhost/root.ts",
"https://localhost/subdir": "./localhost/subdir/root.ts",
}
}))
);
assert_eq!(
output.files,
to_file_vec(&[
("/vendor/localhost/root.ts", "export class Mod1 {}"),
("/vendor/localhost/subdir/root.ts", "export class Mod2 {}"),
("/vendor/localhost/subdir/mod.ts", "export class Mod3 {}"),
]),
);
}
#[tokio::test] #[tokio::test]
async fn same_target_filename_specifiers() { async fn same_target_filename_specifiers() {
let mut builder = VendorTestBuilder::with_default_setup(); let mut builder = VendorTestBuilder::with_default_setup();