Skip to content

Commit

Permalink
Add tests for checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
sundaram123krishnan committed Nov 22, 2024
1 parent 9903dcf commit 0f19b12
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/views/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,39 @@ pub fn labeled_checkbox<S: Display + 'static>(
) -> ValueContainer<bool> {
Checkbox::labeled(checked, label)
}

#[cfg(test)]
mod test {
use super::*;
use floem_reactive::{create_rw_signal, SignalGet, SignalUpdate};

#[test]
fn test_checkbox_new_initial_value() {
let checked = create_rw_signal(false);
let _checkbox = Checkbox::new_rw(checked);
assert_eq!(checked.get(), false);
}

#[test]
fn test_checkbox_new_changes_state() {
let checked = create_rw_signal(false);
let _checkbox = Checkbox::new_rw(checked);
checked.set(true);
assert_eq!(checked.get(), true);
}

#[test]
fn test_checkbox_labeled_initial_value() {
let checked = create_rw_signal(false);
let _labeled_checkbox = Checkbox::labeled_rw(checked, || "Label for checkbox");
assert_eq!(checked.get(), false);
}

#[test]
fn test_checkbox_labeled_changes_state() {
let checked = create_rw_signal(false);
let _labeled_checkbox = Checkbox::labeled_rw(checked, || "Label for checkbox");
checked.set(true);
assert_eq!(checked.get(), true);
}
}

0 comments on commit 0f19b12

Please sign in to comment.