Skip to content

Commit

Permalink
Add tests for into_inner
Browse files Browse the repository at this point in the history
  • Loading branch information
stefnotch committed Dec 10, 2024
1 parent 4002883 commit 354b205
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion reactive_graph/tests/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use reactive_graph::{
owner::Owner,
signal::{arc_signal, signal, ArcRwSignal, RwSignal},
traits::{
Get, GetUntracked, Read, Set, Update, UpdateUntracked, With,
Get, GetUntracked, IntoInner, Read, Set, Update, UpdateUntracked, With,
WithUntracked, Write,
},
};
Expand Down Expand Up @@ -108,3 +108,24 @@ fn update_signal() {
set_a.set(4);
assert_eq!(a.get(), 4);
}

#[test]
fn into_inner_signal() {
let owner = Owner::new();
owner.set();

let rw_signal = RwSignal::new(1);
assert_eq!(rw_signal.get(), 1);
assert_eq!(rw_signal.into_inner(), Some(1));
}

#[test]
fn into_inner_arc_signal() {
let owner = Owner::new();
owner.set();

let (a, b) = arc_signal(2);
assert_eq!(a.get(), 2);
std::mem::drop(b);
assert_eq!(a.into_inner(), Some(2));
}

0 comments on commit 354b205

Please sign in to comment.