Skip to content
This repository has been archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
test: Add test case for parse_crate_data
Browse files Browse the repository at this point in the history
  • Loading branch information
drager committed Nov 13, 2018
1 parent 6894e63 commit 203cf69
Showing 1 changed file with 41 additions and 7 deletions.
48 changes: 41 additions & 7 deletions tests/all/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,9 @@ fn it_does_not_error_when_wasm_bindgen_is_declared() {
#[test]
fn configure_wasm_bindgen_debug_incorrectly_is_error() {
let fixture = utils::fixture::Fixture::new();
fixture
.readme()
.file(
"Cargo.toml",
r#"
fixture.readme().hello_world_src_lib().file(
"Cargo.toml",
r#"
[package]
authors = ["The wasm-pack developers"]
description = "so awesome rust+wasm package"
Expand All @@ -314,8 +312,7 @@ fn configure_wasm_bindgen_debug_incorrectly_is_error() {
[package.metadata.wasm-pack.profile.dev.wasm-bindgen]
debug-js-glue = "not a boolean"
"#,
)
.hello_world_src_lib();
);

let cli = Cli::from_iter_safe(vec![
"wasm-pack",
Expand All @@ -333,3 +330,40 @@ fn configure_wasm_bindgen_debug_incorrectly_is_error() {
.to_string()
.contains("package.metadata.wasm-pack.profile.dev.wasm-bindgen.debug")));
}

#[test]
fn parse_crate_data_returns_unused_keys_in_cargo_toml() {
let fixture = utils::fixture::Fixture::new();
fixture
.readme()
.file(
"Cargo.toml",
r#"
[package]
authors = ["The wasm-pack developers"]
description = "so awesome rust+wasm package"
license = "WTFPL"
name = "whatever"
repository = "https://github.com/rustwasm/wasm-pack.git"
version = "0.1.0"
[lib]
crate-type = ["cdylib"]
[dependencies]
wasm-bindgen = "0.2"
[package.metadata.wasmpack.profile.dev.wasm-bindgen]
debug-js-glue = true
"#,
)
.hello_world_src_lib();

let result = manifest::CrateData::parse_crate_data(&fixture.path.join("Cargo.toml"));

assert!(result.is_ok());

let manifest::ManifestAndUnsedKeys { unused_keys, .. } = result.unwrap();

assert!(unused_keys.contains("package.metadata.wasmpack"));
}

0 comments on commit 203cf69

Please sign in to comment.