|
|
|
@ -49,7 +49,7 @@ fn it_creates_a_package_json_default_path() { |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
let path = ".".to_string(); |
|
|
|
|
wasm_pack::command::init::create_pkg_dir(&path, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&path, &None, false, &step).is_ok()); |
|
|
|
|
assert!(manifest::write_package_json(&path, &None, false, "", &step).is_ok()); |
|
|
|
|
let package_json_path = format!("{}/pkg/package.json", &path); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::read_package_json(&path).is_ok()); |
|
|
|
@ -66,7 +66,7 @@ fn it_creates_a_package_json_default_path() { |
|
|
|
|
|
|
|
|
|
let actual_files: HashSet<String> = pkg.files.into_iter().collect(); |
|
|
|
|
let expected_files: HashSet<String> = |
|
|
|
|
["wasm_pack_bg.wasm", "wasm_pack_bg.js", "wasm_pack.d.ts"] |
|
|
|
|
["wasm_pack_bg.wasm", "wasm_pack.d.ts"] |
|
|
|
|
.iter() |
|
|
|
|
.map(|&s| String::from(s)) |
|
|
|
|
.collect(); |
|
|
|
@ -78,7 +78,7 @@ fn it_creates_a_package_json_provided_path() { |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
let path = "tests/fixtures/js-hello-world".to_string(); |
|
|
|
|
wasm_pack::command::init::create_pkg_dir(&path, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&path, &None, false, &step).is_ok()); |
|
|
|
|
assert!(manifest::write_package_json(&path, &None, false, "", &step).is_ok()); |
|
|
|
|
let package_json_path = format!("{}/pkg/package.json", &path); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::read_package_json(&path).is_ok()); |
|
|
|
@ -89,7 +89,6 @@ fn it_creates_a_package_json_provided_path() { |
|
|
|
|
let actual_files: HashSet<String> = pkg.files.into_iter().collect(); |
|
|
|
|
let expected_files: HashSet<String> = [ |
|
|
|
|
"js_hello_world_bg.wasm", |
|
|
|
|
"js_hello_world_bg.js", |
|
|
|
|
"js_hello_world.d.ts", |
|
|
|
|
].iter() |
|
|
|
|
.map(|&s| String::from(s)) |
|
|
|
@ -102,7 +101,7 @@ fn it_creates_a_package_json_provided_path_with_scope() { |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
let path = "tests/fixtures/scopes".to_string(); |
|
|
|
|
wasm_pack::command::init::create_pkg_dir(&path, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&path, &Some("test".to_string()), false, &step).is_ok()); |
|
|
|
|
assert!(manifest::write_package_json(&path, &Some("test".to_string()), false, "", &step).is_ok()); |
|
|
|
|
let package_json_path = format!("{}/pkg/package.json", &path); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::read_package_json(&path).is_ok()); |
|
|
|
@ -113,7 +112,6 @@ fn it_creates_a_package_json_provided_path_with_scope() { |
|
|
|
|
let actual_files: HashSet<String> = pkg.files.into_iter().collect(); |
|
|
|
|
let expected_files: HashSet<String> = [ |
|
|
|
|
"scopes_hello_world_bg.wasm", |
|
|
|
|
"scopes_hello_world_bg.js", |
|
|
|
|
"scopes_hello_world.d.ts", |
|
|
|
|
].iter() |
|
|
|
|
.map(|&s| String::from(s)) |
|
|
|
@ -121,6 +119,35 @@ fn it_creates_a_package_json_provided_path_with_scope() { |
|
|
|
|
assert_eq!(actual_files, expected_files); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn it_creates_a_pkg_json_with_correct_files_on_node() { |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
let path = ".".to_string(); |
|
|
|
|
wasm_pack::command::init::create_pkg_dir(&path, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&path, &None, false, "nodejs", &step).is_ok()); |
|
|
|
|
let package_json_path = format!("{}/pkg/package.json", &path); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::read_package_json(&path).is_ok()); |
|
|
|
|
let pkg = utils::read_package_json(&path).unwrap(); |
|
|
|
|
assert_eq!(pkg.name, "wasm-pack"); |
|
|
|
|
assert_eq!(pkg.repository.ty, "git"); |
|
|
|
|
assert_eq!( |
|
|
|
|
pkg.repository.url, |
|
|
|
|
"https://github.com/ashleygwilliams/wasm-pack.git" |
|
|
|
|
); |
|
|
|
|
assert_eq!(pkg.main, "wasm_pack.js"); |
|
|
|
|
let types = pkg.types.unwrap_or_default(); |
|
|
|
|
assert_eq!(types, "wasm_pack.d.ts"); |
|
|
|
|
|
|
|
|
|
let actual_files: HashSet<String> = pkg.files.into_iter().collect(); |
|
|
|
|
let expected_files: HashSet<String> = |
|
|
|
|
["wasm_pack_bg.wasm", "wasm_pack_bg.js", "wasm_pack.d.ts"] |
|
|
|
|
.iter() |
|
|
|
|
.map(|&s| String::from(s)) |
|
|
|
|
.collect(); |
|
|
|
|
assert_eq!(actual_files, expected_files); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn it_errors_when_wasm_bindgen_is_not_declared() { |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|