|
|
|
@ -378,6 +378,63 @@ fn it_sets_homepage_field_if_available_in_cargo_toml() { |
|
|
|
|
assert_eq!(pkg.homepage, None); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn it_sets_keywords_field_if_available_in_cargo_toml() { |
|
|
|
|
// When 'homepage' is available
|
|
|
|
|
let fixture = utils::fixture::Fixture::new(); |
|
|
|
|
fixture.hello_world_src_lib().file( |
|
|
|
|
"Cargo.toml", |
|
|
|
|
r#" |
|
|
|
|
[package] |
|
|
|
|
authors = ["The wasm-pack developers"] |
|
|
|
|
description = "so awesome rust+wasm package" |
|
|
|
|
license = "WTFPL" |
|
|
|
|
name = "homepage-field-test" |
|
|
|
|
repository = "https://github.com/rustwasm/wasm-pack.git" |
|
|
|
|
version = "0.1.0" |
|
|
|
|
keywords = ["wasm"] |
|
|
|
|
|
|
|
|
|
[lib] |
|
|
|
|
crate-type = ["cdylib"] |
|
|
|
|
|
|
|
|
|
[dependencies] |
|
|
|
|
wasm-bindgen = "=0.2" |
|
|
|
|
|
|
|
|
|
[dev-dependencies] |
|
|
|
|
wasm-bindgen-test = "=0.2" |
|
|
|
|
"#, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
|
|
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
|
crate_data |
|
|
|
|
.write_package_json(&out_dir, &None, true, Target::Bundler) |
|
|
|
|
.unwrap(); |
|
|
|
|
|
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
|
let keywords = pkg.keywords.clone().unwrap(); |
|
|
|
|
assert!( |
|
|
|
|
keywords.contains(&"wasm".to_string()), |
|
|
|
|
"keywords is not in files: {:?}", |
|
|
|
|
keywords, |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// When 'keywords' is unavailable
|
|
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
|
let out_dir = fixture.path.join("pkg"); |
|
|
|
|
let crate_data = manifest::CrateData::new(&fixture.path, None).unwrap(); |
|
|
|
|
|
|
|
|
|
wasm_pack::command::utils::create_pkg_dir(&out_dir).unwrap(); |
|
|
|
|
crate_data |
|
|
|
|
.write_package_json(&out_dir, &None, true, Target::Bundler) |
|
|
|
|
.unwrap(); |
|
|
|
|
|
|
|
|
|
let pkg = utils::manifest::read_package_json(&fixture.path, &out_dir).unwrap(); |
|
|
|
|
assert_eq!(pkg.keywords, None); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
#[test] |
|
|
|
|
fn it_does_not_error_when_wasm_bindgen_is_declared() { |
|
|
|
|
let fixture = fixture::js_hello_world(); |
|
|
|
|