summaryrefslogtreecommitdiffstats
path: root/vendor/web-sys/tests/wasm/body_element.rs
blob: daf5769ff6aca16a12a6372caaa894afb63ed4c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
use web_sys::HtmlBodyElement;

#[wasm_bindgen(module = "/tests/wasm/element.js")]
extern "C" {
    fn new_body() -> HtmlBodyElement;
}

#[wasm_bindgen_test]
fn test_body_element() {
    let element = new_body();
    assert_eq!(element.text(), "", "Shouldn't have a text");
    element.set_text("boop");
    assert_eq!(element.text(), "boop", "Should have a text");

    // Legacy color setting
    assert_eq!(element.link(), "", "Shouldn't have a link");
    element.set_link("blue");
    assert_eq!(element.link(), "blue", "Should have a link");

    assert_eq!(element.v_link(), "", "Shouldn't have a v_link");
    element.set_v_link("purple");
    assert_eq!(element.v_link(), "purple", "Should have a v_link");

    assert_eq!(element.a_link(), "", "Shouldn't have a a_link");
    element.set_a_link("purple");
    assert_eq!(element.a_link(), "purple", "Should have a a_link");

    assert_eq!(element.bg_color(), "", "Shouldn't have a bg_color");
    element.set_bg_color("yellow");
    assert_eq!(element.bg_color(), "yellow", "Should have a bg_color");

    assert_eq!(element.background(), "", "Shouldn't have a background");
    element.set_background("image");
    assert_eq!(element.background(), "image", "Should have a background");
}