Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ccbrown committed Dec 23, 2024
1 parent 64cbda3 commit f1dd596
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/iocraft/src/hooks/use_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,17 @@ mod tests {
let state_copy = state.clone();
assert_eq!(*state.read(), *state_copy.read());
}

#[test]
fn test_dropped_state() {
let hook = UseStateImpl::new(42);

let mut state = hook.state;
assert_eq!(state.get(), 42);

drop(hook);

assert!(state.try_read().is_none());
assert!(state.try_write().is_none());
}
}

0 comments on commit f1dd596

Please sign in to comment.