Skip to content

Commit

Permalink
test: Start of test.
Browse files Browse the repository at this point in the history
  • Loading branch information
shanecelis committed Dec 1, 2024
1 parent df8a7a8 commit 3da846c
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions tests/simulated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,41 @@ mod simulate_app {
.next()
.is_some());
}
#[test]
fn match_ab_and_c() {
let mut app = new_app();

app.world_mut().add(KeySequence::new(
action::send_event(EventSent(0)),
[KeyCode::KeyA, KeyCode::KeyB],
));
app.world_mut().add(KeySequence::new(
action::send_event(EventSent(1)),
[KeyCode::KeyA],
));
app.world_mut().add(KeySequence::new(
action::send_event(EventSent(2)),
[KeyCode::KeyC],
));
press_key(&mut app, KeyCode::KeyA);
app.update();
assert!(app
.world_mut()
.query::<&EventSent>()
.iter(app.world_mut())
.next()
.is_none());

clear_just_pressed(&mut app, KeyCode::KeyA);
press_key(&mut app, KeyCode::KeyB);
app.update();
assert!(app
.world_mut()
.query::<&EventSent>()
.iter(app.world_mut())
.next()
.map(|x| x.0 == 0).unwrap_or(false));
}

#[test]
fn two_any_patterns() {
Expand Down

0 comments on commit 3da846c

Please sign in to comment.