fork of https://github.com/rustwasm/wasm-pack for the needs of NextGraph.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Ashley Williams 3856db20b9 fix(style): appease cargo fmt 7 years ago
..
utils Execute `cargo metadata` at most once 7 years ago
bindgen.rs Add listing for precompiled Windows binaries 7 years ago
build.rs tests: Make tests run faster by using Fixture builders 7 years ago
lockfile.rs fix(style): appease cargo fmt 7 years ago
main.rs feat(lockfiles): Use `Cargo.lock` to identify wasm-bindgen versions 7 years ago
manifest.rs feat(lockfiles): Use `Cargo.lock` to identify wasm-bindgen versions 7 years ago
readme.rs tests: Make tests run faster by using Fixture builders 7 years ago
test.rs feat(lockfiles): Use `Cargo.lock` to identify wasm-bindgen versions 7 years ago
webdriver.rs tests: Make tests run faster by using Fixture builders 7 years ago

readme.rs

extern crate failure;
extern crate wasm_pack;

use std::fs;

use utils::{self, fixture};
use wasm_pack::readme;

#[test]
fn it_copies_a_readme_default_path() {
let fixture = fixture::js_hello_world();
let out_dir = fixture.path.join("pkg");
fs::create_dir(&out_dir).expect("should create pkg directory OK");

let step = wasm_pack::progressbar::Step::new(1);
assert!(readme::copy_from_crate(&fixture.path, &out_dir, &step).is_ok());

let crate_readme_path = fixture.path.join("README.md");
let pkg_readme_path = out_dir.join("README.md");
println!(
"wasm-pack: should have copied README.md from '{}' to '{}'",
crate_readme_path.display(),
pkg_readme_path.display()
);
assert!(fs::metadata(&crate_readme_path).is_ok());

assert!(fs::metadata(&pkg_readme_path).is_ok());

let crate_readme = utils::file::read_file(&crate_readme_path).unwrap();
let pkg_readme = utils::file::read_file(&pkg_readme_path).unwrap();
assert_eq!(crate_readme, pkg_readme);
}

#[test]
fn it_creates_a_package_json_provided_path() {
let fixture = fixture::js_hello_world();
let out_dir = fixture.path.join("pkg");
fs::create_dir(&out_dir).expect("should create pkg directory OK");

let step = wasm_pack::progressbar::Step::new(1);
assert!(readme::copy_from_crate(&fixture.path, &out_dir, &step).is_ok());
let crate_readme_path = fixture.path.join("README.md");
let pkg_readme_path = out_dir.join("README.md");
println!(
"wasm-pack: should have copied README.md from '{}' to '{}'",
crate_readme_path.display(),
pkg_readme_path.display()
);
assert!(fs::metadata(&crate_readme_path).is_ok());
assert!(fs::metadata(&pkg_readme_path).is_ok());

let crate_readme = utils::file::read_file(&crate_readme_path).unwrap();
let pkg_readme = utils::file::read_file(&pkg_readme_path).unwrap();
assert_eq!(crate_readme, pkg_readme);
}