From 286bed9c276b3d1af42eb80e5998ffd84705d4bf Mon Sep 17 00:00:00 2001 From: Ashley Williams Date: Fri, 21 Sep 2018 12:16:24 -0400 Subject: [PATCH] test(no-modules): no-modules works --- tests/all/manifest.rs | 35 +++++++++++++++++++++++++++++++++++ tests/all/utils/manifest.rs | 2 ++ 2 files changed, 37 insertions(+) diff --git a/tests/all/manifest.rs b/tests/all/manifest.rs index 1a94819..8d84e35 100644 --- a/tests/all/manifest.rs +++ b/tests/all/manifest.rs @@ -179,6 +179,41 @@ fn it_creates_a_pkg_json_with_correct_files_on_node() { assert_eq!(actual_files, expected_files); } +#[test] +fn it_creates_a_pkg_json_with_correct_files_on_nomodules() { + let fixture = fixture::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(&out_dir, &step).unwrap(); + assert!( + manifest::write_package_json(&fixture.path, &out_dir, &None, false, "no-modules", &step) + .is_ok() + ); + let package_json_path = &out_dir.join("package.json"); + assert!(fs::metadata(package_json_path).is_ok()); + utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); + let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); + assert_eq!(pkg.name, "js-hello-world"); + assert_eq!(pkg.repository.ty, "git"); + assert_eq!( + pkg.repository.url, + "https://github.com/rustwasm/wasm-pack.git" + ); + assert_eq!(pkg.browser, "js_hello_world.js"); + assert_eq!(pkg.types, "js_hello_world.d.ts"); + + let actual_files: HashSet = pkg.files.into_iter().collect(); + let expected_files: HashSet = [ + "js_hello_world_bg.wasm", + "js_hello_world.js", + "js_hello_world.d.ts", + ] + .iter() + .map(|&s| String::from(s)) + .collect(); + assert_eq!(actual_files, expected_files); +} + #[test] fn it_creates_a_pkg_json_in_out_dir() { let fixture = fixture::js_hello_world(); diff --git a/tests/all/utils/manifest.rs b/tests/all/utils/manifest.rs index ebc767d..2f811ec 100644 --- a/tests/all/utils/manifest.rs +++ b/tests/all/utils/manifest.rs @@ -18,6 +18,8 @@ pub struct NpmPackage { #[serde(default = "default_none")] pub module: String, #[serde(default = "default_none")] + pub browser: String, + #[serde(default = "default_none")] pub types: String, #[serde(default = "default_none", rename = "sideEffects")] pub side_effects: String,