mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 12:31:22 +00:00
Port Intl
tests to wasm
This commit is contained in:
25
crates/js-sys/tests/wasm/Intl.rs
Normal file
25
crates/js-sys/tests/wasm/Intl.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use wasm_bindgen::JsValue;
|
||||
use wasm_bindgen_test::*;
|
||||
use js_sys::*;
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn get_canonical_locales() {
|
||||
let locales = Array::new();
|
||||
locales.push("EN-US".into());
|
||||
locales.push("Fr".into());
|
||||
let locales = JsValue::from(locales);
|
||||
let canonical_locales = Intl::get_canonical_locales(&locales);
|
||||
assert_eq!(canonical_locales.length(), 2);
|
||||
canonical_locales.for_each(&mut |l, i, _| {
|
||||
if i == 0 {
|
||||
assert_eq!(l, "en-US");
|
||||
} else {
|
||||
assert_eq!(l, "fr");
|
||||
}
|
||||
});
|
||||
let canonical_locales = Intl::get_canonical_locales(&"EN-US".into());
|
||||
assert_eq!(canonical_locales.length(), 1);
|
||||
canonical_locales.for_each(&mut |l, _, _| {
|
||||
assert_eq!(l, "en-US");
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user