diff --git a/packages/pinball_components/test/src/components/plunger_test.dart b/packages/pinball_components/test/src/components/plunger_test.dart index c7e3f7d9..8f67aa3b 100644 --- a/packages/pinball_components/test/src/components/plunger_test.dart +++ b/packages/pinball_components/test/src/components/plunger_test.dart @@ -1,5 +1,6 @@ // ignore_for_file: cascade_invocations +import 'package:flame/components.dart'; import 'package:flame_forge2d/flame_forge2d.dart'; import 'package:flame_test/flame_test.dart'; import 'package:flutter_test/flutter_test.dart'; @@ -149,6 +150,33 @@ void main() { expect(plunger.body.linearVelocity.y, isPositive); expect(plunger.body.linearVelocity.x, isZero); }); + + flameTester.test( + 'animates when called', + (game) async { + await game.ensureAdd(plunger); + + plunger.pull(); + + final animation = + plunger.descendants().whereType().first; + expect(animation.playing, isTrue); + }, + ); + + flameTester.test( + 'stops animating after animation completes', + (game) async { + await game.ensureAdd(plunger); + + plunger.pull(); + game.update(1); + + final animation = + plunger.descendants().whereType().first; + expect(animation.playing, isFalse); + }, + ); }); group('release', () { @@ -182,6 +210,35 @@ void main() { expect(plunger.body.linearVelocity.x, isZero); }, ); + + flameTester.test( + 'animates when called', + (game) async { + await game.ensureAdd(plunger); + + plunger.pull(); + plunger.release(); + + final animation = + plunger.descendants().whereType().first; + expect(animation.playing, isTrue); + }, + ); + + flameTester.test( + 'stops animating after animation completes', + (game) async { + await game.ensureAdd(plunger); + + plunger.pull(); + plunger.release(); + game.update(1); + + final animation = + plunger.descendants().whereType().first; + expect(animation.playing, isFalse); + }, + ); }); });