File: body_element.rs

package info (click to toggle)
rustc-web 1.78.0%2Bdfsg1-2~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,245,420 kB
  • sloc: xml: 147,985; javascript: 18,022; sh: 11,083; python: 10,265; ansic: 6,172; cpp: 5,023; asm: 4,390; makefile: 4,269
file content (37 lines) | stat: -rw-r--r-- 1,305 bytes parent folder | download | duplicates (5)
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");
}