Skip to content

Commit e6b5ca5

Browse files
committed
test(manifest): update test cases
1 parent 75db2a8 commit e6b5ca5

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tests/manifest/main.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn it_gets_the_crate_name_provided_path() {
2929
fn it_creates_a_package_json_default_path() {
3030
let path = ".".to_string();
3131
wasm_pack::command::create_pkg_dir(&path).unwrap();
32-
assert!(manifest::write_package_json(&path, None).is_ok());
32+
assert!(manifest::write_package_json(&path, None, false).is_ok());
3333
let package_json_path = format!("{}/pkg/package.json", &path);
3434
assert!(fs::metadata(package_json_path).is_ok());
3535
assert!(utils::read_package_json(&path).is_ok());
@@ -42,13 +42,15 @@ fn it_creates_a_package_json_default_path() {
4242
);
4343
assert_eq!(pkg.files, ["wasm_pack_bg.wasm"]);
4444
assert_eq!(pkg.main, "wasm_pack.js");
45+
let types = pkg.types.unwrap_or_default();
46+
assert_eq!(types, "wasm_pack.d.ts");
4547
}
4648

4749
#[test]
4850
fn it_creates_a_package_json_provided_path() {
4951
let path = "tests/fixtures/js-hello-world".to_string();
5052
wasm_pack::command::create_pkg_dir(&path).unwrap();
51-
assert!(manifest::write_package_json(&path, None).is_ok());
53+
assert!(manifest::write_package_json(&path, None, false).is_ok());
5254
let package_json_path = format!("{}/pkg/package.json", &path);
5355
assert!(fs::metadata(package_json_path).is_ok());
5456
assert!(utils::read_package_json(&path).is_ok());
@@ -60,7 +62,7 @@ fn it_creates_a_package_json_provided_path() {
6062
fn it_creates_a_package_json_provided_path_with_scope() {
6163
let path = "tests/fixtures/scopes".to_string();
6264
wasm_pack::command::create_pkg_dir(&path).unwrap();
63-
assert!(manifest::write_package_json(&path, Some("test".to_string())).is_ok());
65+
assert!(manifest::write_package_json(&path, Some("test".to_string()), false).is_ok());
6466
let package_json_path = format!("{}/pkg/package.json", &path);
6567
assert!(fs::metadata(package_json_path).is_ok());
6668
assert!(utils::read_package_json(&path).is_ok());

tests/manifest/utils.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct NpmPackage {
1313
pub repository: Repository,
1414
pub files: Vec<String>,
1515
pub main: String,
16+
pub types: Option<String>,
1617
}
1718

1819
#[derive(Deserialize)]

0 commit comments

Comments
 (0)