feat(sprint-14): add GiftBox RESETTING auto-reset state
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
## Tests for GiftBox — CLOSED/OPENING/OPEN state machine transitions.
|
||||
## Tests for GiftBox — CLOSED/OPENING/RESETTING state machine transitions.
|
||||
extends GutTest
|
||||
|
||||
var _box: GiftBox
|
||||
@@ -23,10 +23,10 @@ func test_start_opening_transitions_to_opening() -> void:
|
||||
assert_eq(_box._state, GiftBox.State.OPENING)
|
||||
|
||||
|
||||
func test_on_lid_opened_transitions_to_open() -> void:
|
||||
func test_on_lid_opened_transitions_to_resetting() -> void:
|
||||
_box._start_opening()
|
||||
_box._on_lid_opened()
|
||||
assert_eq(_box._state, GiftBox.State.OPEN)
|
||||
assert_eq(_box._state, GiftBox.State.RESETTING)
|
||||
|
||||
|
||||
func test_input_ignored_when_state_is_opening() -> void:
|
||||
@@ -38,13 +38,13 @@ func test_input_ignored_when_state_is_opening() -> void:
|
||||
assert_eq(_box._state, GiftBox.State.OPENING)
|
||||
|
||||
|
||||
func test_input_ignored_when_state_is_open() -> void:
|
||||
_box._state = GiftBox.State.OPEN
|
||||
func test_input_ignored_when_state_is_resetting() -> void:
|
||||
_box._state = GiftBox.State.RESETTING
|
||||
var event: InputEventScreenTouch = InputEventScreenTouch.new()
|
||||
event.pressed = true
|
||||
event.position = _box.global_position
|
||||
_box._input(event)
|
||||
assert_eq(_box._state, GiftBox.State.OPEN)
|
||||
assert_eq(_box._state, GiftBox.State.RESETTING)
|
||||
|
||||
|
||||
func test_tap_outside_hitbox_does_not_open() -> void:
|
||||
@@ -61,3 +61,9 @@ func test_release_event_does_not_open() -> void:
|
||||
event.position = _box.global_position
|
||||
_box._input(event)
|
||||
assert_eq(_box._state, GiftBox.State.CLOSED)
|
||||
|
||||
|
||||
func test_on_reset_complete_transitions_to_closed() -> void:
|
||||
_box._state = GiftBox.State.RESETTING
|
||||
_box._on_reset_complete()
|
||||
assert_eq(_box._state, GiftBox.State.CLOSED)
|
||||
|
||||
Reference in New Issue
Block a user