test: tests and golden test for plunger

pull/200/head
RuiAlonso 3 years ago
parent f03c7ffcde
commit 02762c9e8a

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

@ -25,7 +25,16 @@ void main() {
verify: (game, tester) async {
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/plunger.png'),
matchesGoldenFile('golden/plunger/start.png'),
);
final plunger = game.descendants().whereType<Plunger>().first;
plunger.pull();
game.update(1);
await tester.pump();
await expectLater(
find.byGame<TestGame>(),
matchesGoldenFile('golden/plunger/end.png'),
);
},
);
@ -110,12 +119,17 @@ void main() {
});
group('pull', () {
late Plunger plunger;
setUp(() {
plunger = Plunger(
compressionDistance: compressionDistance,
);
});
flameTester.test(
'moves downwards when pull is called',
(game) async {
final plunger = Plunger(
compressionDistance: compressionDistance,
);
await game.ensureAdd(plunger);
plunger.pull();
@ -123,6 +137,18 @@ void main() {
expect(plunger.body.linearVelocity.x, isZero);
},
);
flameTester.test(
'moves downwards when pull is called '
'and plunger is below its starting position', (game) async {
await game.ensureAdd(plunger);
plunger.pull();
plunger.release();
plunger.pull();
expect(plunger.body.linearVelocity.y, isPositive);
expect(plunger.body.linearVelocity.x, isZero);
});
});
group('release', () {

Loading…
Cancel
Save