create test for deserealization of result of js function
This commit is contained in:
parent
534a0e6090
commit
5c8cadf7a0
@ -159,6 +159,22 @@ mod tests {
|
|||||||
println!("o: {:?}", recursive_format(o));
|
println!("o: {:?}", recursive_format(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_func_deserialization_main() {
|
||||||
|
let runner = Runner::init().unwrap();
|
||||||
|
let _ = runner
|
||||||
|
.run_script("function cancel_buttons() {return 'cancelation'}")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let f = BotFunction("cancel_buttons".to_string());
|
||||||
|
let res = f.call_context(&runner).unwrap();
|
||||||
|
|
||||||
|
println!("RES: {res:?}");
|
||||||
|
let sres: String = res.js_into().unwrap();
|
||||||
|
println!("Deserialized RES: {:?}", sres);
|
||||||
|
assert_eq!(sres, "cancelation");
|
||||||
|
}
|
||||||
|
|
||||||
fn recursive_format(o: OwnedJsObject) -> String {
|
fn recursive_format(o: OwnedJsObject) -> String {
|
||||||
let props: Vec<_> = o.properties_iter().unwrap().map(|x| x.unwrap()).collect();
|
let props: Vec<_> = o.properties_iter().unwrap().map(|x| x.unwrap()).collect();
|
||||||
let sp: Vec<String> = props
|
let sp: Vec<String> = props
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user