File: option_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 (87 lines) | stat: -rw-r--r-- 2,130 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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
use wasm_bindgen_test::*;
use web_sys::HtmlOptionElement;

#[wasm_bindgen_test]
fn test_option_element() {
    let option = HtmlOptionElement::new_with_text_and_value_and_default_selected_and_selected(
        "option_text",
        "option_value",
        false,
        true,
    )
    .unwrap();

    option.set_disabled(true);
    assert_eq!(
        option.disabled(),
        true,
        "Option should be disabled after we set it to be disabled."
    );

    option.set_disabled(false);
    assert_eq!(
        option.disabled(),
        false,
        "Option should not be disabled after we set it to be not-disabled."
    );

    assert!(
        option.form().is_none(),
        "Our option should not be associated with a form."
    );

    option.set_label("Well this truly is a neat option");
    assert_eq!(
        option.label(),
        "Well this truly is a neat option",
        "Option should have the label we gave it."
    );

    option.set_default_selected(true);
    assert_eq!(
        option.default_selected(),
        true,
        "Option should be default_selected after we set it to be default_selected."
    );

    option.set_default_selected(false);
    assert_eq!(
        option.default_selected(),
        false,
        "Option should not be default_selected after we set it to be not default_selected."
    );

    option.set_selected(true);
    assert_eq!(
        option.selected(),
        true,
        "Option should be selected after we set it to be selected."
    );

    option.set_selected(false);
    assert_eq!(
        option.selected(),
        false,
        "Option should not be selected after we set it to be not selected."
    );

    option.set_value("tomato");
    assert_eq!(
        option.value(),
        "tomato",
        "Option should have the value we gave it."
    );

    option.set_text("potato");
    assert_eq!(
        option.text(),
        "potato",
        "Option should have the text we gave it."
    );

    assert_eq!(
        option.index(),
        0,
        "This should be the first option, since there are no other known options."
    );
}