|
|
|
@ -54,13 +54,14 @@ fn it_recognizes_a_map_during_depcheck() { |
|
|
|
|
#[test] |
|
|
|
|
fn it_creates_a_package_json_default_path() { |
|
|
|
|
let fixture = fixture::fixture("."); |
|
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&fixture.path, &None, false, "", &step).is_ok()); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&fixture.path, &out_dir, &None, false, "", &step).is_ok()); |
|
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path).unwrap(); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
|
assert_eq!(pkg.name, "wasm-pack"); |
|
|
|
|
assert_eq!(pkg.repository.ty, "git"); |
|
|
|
|
assert_eq!( |
|
|
|
@ -82,13 +83,14 @@ fn it_creates_a_package_json_default_path() { |
|
|
|
|
#[test] |
|
|
|
|
fn it_creates_a_package_json_provided_path() { |
|
|
|
|
let fixture = fixture::fixture("tests/fixtures/js-hello-world"); |
|
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&fixture.path, &None, false, "", &step).is_ok()); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&fixture.path, &out_dir, &None, false, "", &step).is_ok()); |
|
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path).unwrap(); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
|
assert_eq!(pkg.name, "js-hello-world"); |
|
|
|
|
assert_eq!(pkg.main, "js_hello_world.js"); |
|
|
|
|
|
|
|
|
@ -103,16 +105,23 @@ fn it_creates_a_package_json_provided_path() { |
|
|
|
|
#[test] |
|
|
|
|
fn it_creates_a_package_json_provided_path_with_scope() { |
|
|
|
|
let fixture = fixture::fixture("tests/fixtures/scopes"); |
|
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap(); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
|
assert!( |
|
|
|
|
manifest::write_package_json(&fixture.path, &Some("test".to_string()), false, "", &step) |
|
|
|
|
.is_ok() |
|
|
|
|
manifest::write_package_json( |
|
|
|
|
&fixture.path, |
|
|
|
|
&out_dir, |
|
|
|
|
&Some("test".to_string()), |
|
|
|
|
false, |
|
|
|
|
"", |
|
|
|
|
&step |
|
|
|
|
).is_ok() |
|
|
|
|
); |
|
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path).unwrap(); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
|
assert_eq!(pkg.name, "@test/scopes-hello-world"); |
|
|
|
|
assert_eq!(pkg.main, "scopes_hello_world.js"); |
|
|
|
|
|
|
|
|
@ -127,13 +136,17 @@ fn it_creates_a_package_json_provided_path_with_scope() { |
|
|
|
|
#[test] |
|
|
|
|
fn it_creates_a_pkg_json_with_correct_files_on_node() { |
|
|
|
|
let fixture = fixture::fixture("."); |
|
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&fixture.path, &None, false, "nodejs", &step).is_ok()); |
|
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
|
assert!( |
|
|
|
|
manifest::write_package_json(&fixture.path, &out_dir, &None, false, "nodejs", &step) |
|
|
|
|
.is_ok() |
|
|
|
|
); |
|
|
|
|
let package_json_path = &out_dir.join("package.json"); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path).unwrap(); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
|
assert_eq!(pkg.name, "wasm-pack"); |
|
|
|
|
assert_eq!(pkg.repository.ty, "git"); |
|
|
|
|
assert_eq!( |
|
|
|
@ -153,16 +166,43 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() { |
|
|
|
|
assert_eq!(actual_files, expected_files); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn it_creates_a_pkg_json_in_out_dir() { |
|
|
|
|
let fixture = fixture::fixture("tests/fixtures/js-hello-world"); |
|
|
|
|
let out_dir = fixture.path.join("./custom/out"); |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&fixture.path, &out_dir, &None, false, "", &step).is_ok()); |
|
|
|
|
|
|
|
|
|
let package_json_path = &fixture.path.join(&out_dir).join("package.json"); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
|
|
|
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
|
assert_eq!(pkg.name, "js-hello-world"); |
|
|
|
|
assert_eq!(pkg.main, "js_hello_world.js"); |
|
|
|
|
|
|
|
|
|
let actual_files: HashSet<String> = pkg.files.into_iter().collect(); |
|
|
|
|
|
|
|
|
|
let expected_files: HashSet<String> = ["js_hello_world_bg.wasm", "js_hello_world.d.ts"] |
|
|
|
|
.iter() |
|
|
|
|
.map(|&s| String::from(s)) |
|
|
|
|
.collect(); |
|
|
|
|
|
|
|
|
|
assert_eq!(actual_files, expected_files); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn it_creates_a_package_json_with_correct_keys_when_types_are_skipped() { |
|
|
|
|
let fixture = fixture::fixture("."); |
|
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
let step = wasm_pack::progressbar::Step::new(1); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&fixture.path, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&fixture.path, &None, true, "", &step).is_ok()); |
|
|
|
|
let package_json_path = &fixture.path.join("pkg").join("package.json"); |
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir, &step).unwrap(); |
|
|
|
|
assert!(manifest::write_package_json(&fixture.path, &out_dir, &None, true, "", &step).is_ok()); |
|
|
|
|
let package_json_path = &out_dir.join("package.json"); |
|
|
|
|
assert!(fs::metadata(package_json_path).is_ok()); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path).unwrap(); |
|
|
|
|
assert!(utils::manifest::read_package_json(&fixture.path, &out_dir).is_ok()); |
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
|
assert_eq!(pkg.name, "wasm-pack"); |
|
|
|
|
assert_eq!(pkg.repository.ty, "git"); |
|
|
|
|
assert_eq!( |
|
|
|
|