From a81a91a95e7d13f419f41e6650b59215404ce8aa Mon Sep 17 00:00:00 2001 From: alestiago Date: Mon, 21 Mar 2022 11:15:29 +0000 Subject: [PATCH] refactor: renamed tests --- test/game/components/ball_test.dart | 82 ++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 26 deletions(-) diff --git a/test/game/components/ball_test.dart b/test/game/components/ball_test.dart index 2870b7c4..369a57dd 100644 --- a/test/game/components/ball_test.dart +++ b/test/game/components/ball_test.dart @@ -35,6 +35,26 @@ void main() { expect(ball.body.bodyType, equals(BodyType.dynamic)); }, ); + + group('can be moved', () { + flameTester.test('by its weight', (game) async { + final ball = Ball(); + await game.ensureAdd(ball); + + game.update(1); + expect(ball.body.position, isNot(equals(ball.initialPosition))); + }); + + flameTester.test('by applying velocity', (game) async { + final ball = Ball(); + await game.ensureAdd(ball); + + ball.body.gravityScale = 0; + ball.body.linearVelocity.setValues(10, 10); + game.update(1); + expect(ball.body.position, isNot(equals(ball.initialPosition))); + }); + }); }); group('fixture', () { @@ -152,27 +172,22 @@ void main() { }); group('stop', () { - flameTester.test('can be moved', (game) async { - final ball = Ball(); - await game.ensureAdd(ball); - - game.update(1); - expect(ball.body.position, isNot(equals(ball.initialPosition))); + group("can't be moved", () { + flameTester.test('by its weight', (game) async { + final ball = Ball(); + await game.ensureAdd(ball); + ball.stop(); - ball.body.gravityScale = 0; - ball.body.linearVelocity.setValues(10, 10); - game.update(1); - expect(ball.body.position, isNot(equals(ball.initialPosition))); + game.update(1); + expect(ball.body.position, equals(ball.initialPosition)); + }); }); - flameTester.test("can't be moved", (game) async { + flameTester.test('by applying velocity', (game) async { final ball = Ball(); await game.ensureAdd(ball); ball.stop(); - game.update(1); - expect(ball.body.position, equals(ball.initialPosition)); - ball.body.linearVelocity.setValues(10, 10); game.update(1); expect(ball.body.position, equals(ball.initialPosition)); @@ -180,19 +195,34 @@ void main() { }); group('resume', () { - flameTester.test('can move when previosusly stopped', (game) async { - final ball = Ball(); - await game.ensureAdd(ball); - ball.stop(); - ball.resume(); - - game.update(1); - expect(ball.body.position, isNot(equals(ball.initialPosition))); + group('can move', () { + flameTester.test( + 'by its weight when previously stopped', + (game) async { + final ball = Ball(); + await game.ensureAdd(ball); + ball.stop(); + ball.resume(); + + game.update(1); + expect(ball.body.position, isNot(equals(ball.initialPosition))); + }, + ); - ball.body.gravityScale = 0; - ball.body.linearVelocity.setValues(10, 10); - game.update(1); - expect(ball.body.position, isNot(equals(ball.initialPosition))); + flameTester.test( + 'by applying velocity when previously stopped', + (game) async { + final ball = Ball(); + await game.ensureAdd(ball); + ball.stop(); + ball.resume(); + + ball.body.gravityScale = 0; + ball.body.linearVelocity.setValues(10, 10); + game.update(1); + expect(ball.body.position, isNot(equals(ball.initialPosition))); + }, + ); }); }); });