Use sets to compare package.json files content

Order doesn't matter!
master
Ian McIntyre 7 years ago committed by Ashley Williams
parent bf222549af
commit e9b05b2181
  1. 10
      tests/manifest/main.rs

@ -6,6 +6,7 @@ extern crate wasm_pack;
mod utils;
use std::collections::HashSet;
use std::fs;
use wasm_pack::manifest;
@ -59,10 +60,17 @@ fn it_creates_a_package_json_default_path() {
pkg.repository.url,
"https://github.com/ashleygwilliams/wasm-pack.git"
);
assert_eq!(pkg.files, ["wasm_pack_bg.wasm", "wasm_pack_bg.js", "wasm_pack.d.ts"]);
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]

Loading…
Cancel
Save