summaryrefslogtreecommitdiffstats
path: root/vendor/web-sys/tests/wasm/anchor_element.rs
blob: 7f09c25011ba757d86659f57ddbf7d0338e1ad49 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
use web_sys::HtmlAnchorElement;

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

#[wasm_bindgen_test]
fn test_anchor_element() {
    let element = new_a();
    assert_eq!(element.target(), "", "Shouldn't have a target");
    element.set_target("_blank");
    assert_eq!(element.target(), "_blank", "Should have a target");

    assert_eq!(element.download(), "", "Shouldn't have a download");
    element.set_download("boop.png");
    assert_eq!(element.download(), "boop.png", "Should have a download");

    assert_eq!(element.ping(), "", "Shouldn't have a ping");
    element.set_ping("boop");
    assert_eq!(element.ping(), "boop", "Should have a ping");

    assert_eq!(element.rel(), "", "Shouldn't have a rel");
    element.set_rel("boop");
    assert_eq!(element.rel(), "boop", "Should have a rel");

    assert_eq!(
        element.referrer_policy(),
        "",
        "Shouldn't have a referrer_policy"
    );
    element.set_referrer_policy("origin");
    assert_eq!(
        element.referrer_policy(),
        "origin",
        "Should have a referrer_policy"
    );

    assert_eq!(element.hreflang(), "", "Shouldn't have a hreflang");
    element.set_hreflang("en-us");
    assert_eq!(element.hreflang(), "en-us", "Should have a hreflang");

    assert_eq!(element.type_(), "", "Shouldn't have a type");
    element.set_type("text/plain");
    assert_eq!(element.type_(), "text/plain", "Should have a type");

    assert_eq!(element.text().unwrap(), "", "Shouldn't have a text");
    element.set_text("Click me!").unwrap();
    assert_eq!(element.text().unwrap(), "Click me!", "Should have a text");

    assert_eq!(element.coords(), "", "Shouldn't have a coords");
    element.set_coords("1,2,3");
    assert_eq!(element.coords(), "1,2,3", "Should have a coords");

    assert_eq!(element.charset(), "", "Shouldn't have a charset");
    element.set_charset("thing");
    assert_eq!(element.charset(), "thing", "Should have a charset");

    assert_eq!(element.name(), "", "Shouldn't have a name");
    element.set_name("thing");
    assert_eq!(element.name(), "thing", "Should have a name");

    assert_eq!(element.rev(), "", "Shouldn't have a rev");
    element.set_rev("thing");
    assert_eq!(element.rev(), "thing", "Should have a rev");

    assert_eq!(element.shape(), "", "Shouldn't have a shape");
    element.set_shape("thing");
    assert_eq!(element.shape(), "thing", "Should have a shape");
}