Skip to content

Commit

Permalink
Add unit test for binding
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Oct 19, 2024
1 parent 2d7ef61 commit 8ab2a6e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/input_context/context_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,3 +382,25 @@ impl GamepadStick {
}
}
}

#[cfg(test)]
mod tests {
use bevy_enhanced_input_macros::InputAction;

use super::*;

#[test]
fn bind() {
let mut ctx = ContextInstance::default();
ctx.bind::<DummyAction>().with(KeyCode::KeyA);
ctx.bind::<DummyAction>().with(KeyCode::KeyB);
assert_eq!(ctx.bindings.len(), 1);

let action = ctx.bindings.first().unwrap();
assert_eq!(action.bindings.len(), 2);
}

#[derive(Debug, InputAction)]
#[input_action(dim = Bool)]
struct DummyAction;
}

0 comments on commit 8ab2a6e

Please sign in to comment.