Add binding for Object.entries()

This commit is contained in:
Michael Hoffmann
2018-09-19 21:32:05 +02:00
parent 326e4c0262
commit f7b511588b
2 changed files with 23 additions and 0 deletions

View File

@ -110,6 +110,19 @@ fn define_properties() {
assert!(foo.has_own_property(&"car".into()));
}
#[wasm_bindgen_test]
fn entries() {
let entries = Object::entries(&foo_42());
assert_eq!(entries.length(), 1);
entries.for_each(&mut |x, _, _| {
assert!(x.is_object());
let array: Array = x.into();
assert_eq!(array.shift(), "foo");
assert_eq!(array.shift(), 42);
assert_eq!(array.length(), 0);
});
}
#[wasm_bindgen_test]
fn get_own_property_descriptor() {
let foo = foo_42();