mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-18 07:11:56 +03:00
6eef5f7b52
* Move the `js` module to a `js_sys` crate * Update js-sys tests to pass again * Update binding_to_unimplemented_apis_doesnt_break_everything Remove its dependency on the `js` module * Update metadata for js-sys * Fix the `closures` example
34 lines
992 B
Rust
34 lines
992 B
Rust
#![allow(non_snake_case)]
|
|
|
|
use project;
|
|
|
|
#[test]
|
|
fn get_canonical_locales() {
|
|
project()
|
|
.file("src/lib.rs", r#"
|
|
#![feature(use_extern_macros)]
|
|
|
|
extern crate wasm_bindgen;
|
|
extern crate js_sys;
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
#[wasm_bindgen]
|
|
pub fn get_canonical_locales(v: &JsValue) -> js_sys::Array {
|
|
js_sys::Intl::get_canonical_locales(v)
|
|
}
|
|
"#)
|
|
.file("test.js", r#"
|
|
import * as assert from "assert";
|
|
import * as wasm from "./out";
|
|
|
|
export function test() {
|
|
let locales = ["EN-US", "Fr"];
|
|
let canonical_locales = wasm.get_canonical_locales(locales);
|
|
assert.deepStrictEqual(canonical_locales, ["en-US", "fr"]);
|
|
|
|
let single_locale = wasm.get_canonical_locales("EN-US");
|
|
assert.equal(single_locale, "en-US");
|
|
}
|
|
"#)
|
|
.test()
|
|
} |