2018-07-20 22:21:41 +03:00
|
|
|
use wasm_bindgen::JsValue;
|
|
|
|
use wasm_bindgen_test::*;
|
|
|
|
use js_sys::*;
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn new() {
|
2018-07-26 02:50:30 +03:00
|
|
|
let error = Error::new("some message");
|
2018-07-20 22:21:41 +03:00
|
|
|
assert_eq!(JsValue::from(error.message()), "some message");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn set_message() {
|
2018-07-26 02:50:30 +03:00
|
|
|
let error = Error::new("test");
|
|
|
|
error.set_message("another");
|
2018-07-20 22:21:41 +03:00
|
|
|
assert_eq!(JsValue::from(error.message()), "another");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn name() {
|
2018-07-26 02:50:30 +03:00
|
|
|
let error = Error::new("test");
|
2018-07-20 22:21:41 +03:00
|
|
|
assert_eq!(JsValue::from(error.name()), "Error");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn set_name() {
|
2018-07-26 02:50:30 +03:00
|
|
|
let error = Error::new("test");
|
|
|
|
error.set_name("different");
|
2018-07-20 22:21:41 +03:00
|
|
|
assert_eq!(JsValue::from(error.name()), "different");
|
|
|
|
}
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn to_string() {
|
2018-07-26 02:50:30 +03:00
|
|
|
let error = Error::new("error message 1");
|
2018-07-20 22:21:41 +03:00
|
|
|
assert_eq!(JsValue::from(error.to_string()), "Error: error message 1");
|
2018-07-26 02:50:30 +03:00
|
|
|
error.set_name("error_name_1");
|
2018-07-20 22:21:41 +03:00
|
|
|
assert_eq!(JsValue::from(error.to_string()), "error_name_1: error message 1");
|
|
|
|
}
|