diff --git a/lib/game/components/plunger.dart b/lib/game/components/plunger.dart index caef1670..ed1ef36f 100644 --- a/lib/game/components/plunger.dart +++ b/lib/game/components/plunger.dart @@ -57,7 +57,7 @@ class PlungerAnchorPrismaticJointDef extends PrismaticJointDef { required Anchor anchor, }) : assert( anchor.body.position.y < plunger.body.position.y, - "Anchor can't be positioned above the Plunger", + 'Anchor must be below the Plunger', ) { initialize( plunger.body, diff --git a/test/game/components/plunger_test.dart b/test/game/components/plunger_test.dart index 5d3c3a55..67e215fd 100644 --- a/test/game/components/plunger_test.dart +++ b/test/game/components/plunger_test.dart @@ -164,6 +164,23 @@ void main() { }, ); + flameTester.test( + 'throws AssertionError ' + 'when anchor is in same position as plunger', + (game) async { + final anchor = Anchor(position: Vector2.zero()); + await game.ensureAddAll([plunger, anchor]); + + expect( + () => PlungerAnchorPrismaticJointDef( + plunger: plunger, + anchor: anchor, + ), + throwsAssertionError, + ); + }, + ); + group('initializes with', () { flameTester.test( 'plunger body as bodyA',