test: refactored tests

pull/87/head
RuiAlonso 4 years ago
parent dcf1742fc9
commit ac21261818

@ -1,7 +1,6 @@
// ignore_for_file: cascade_invocations // ignore_for_file: cascade_invocations
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flame/components.dart';
import 'package:flame_forge2d/flame_forge2d.dart'; import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flame_test/flame_test.dart'; import 'package:flame_test/flame_test.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';

@ -12,12 +12,10 @@ void main() {
center: Vector2.zero(), center: Vector2.zero(),
arcRadius: 10, arcRadius: 10,
angle: 2 * math.pi, angle: 2 * math.pi,
rotation: 0,
), ),
isNotNull, isNotNull,
); );
}); });
});
group('copyWith', () { group('copyWith', () {
test( test(
@ -27,7 +25,6 @@ void main() {
center: Vector2.zero(), center: Vector2.zero(),
arcRadius: 10, arcRadius: 10,
angle: 2 * math.pi, angle: 2 * math.pi,
rotation: 0,
); );
final arcShapeCopied = arcShape.copyWith(); final arcShapeCopied = arcShape.copyWith();
@ -52,7 +49,6 @@ void main() {
center: Vector2.zero(), center: Vector2.zero(),
arcRadius: 10, arcRadius: 10,
angle: math.pi, angle: math.pi,
rotation: 0,
).copyWith( ).copyWith(
center: Vector2.all(10), center: Vector2.all(10),
arcRadius: 15, arcRadius: 15,
@ -68,4 +64,5 @@ void main() {
} }
}); });
}); });
});
} }

@ -6,9 +6,6 @@ import 'package:pinball_components/src/components/components.dart';
void main() { void main() {
group('BezierCurveShape', () { group('BezierCurveShape', () {
group('rotate', () {
test('returns vertices rotated', () {
const rotationAngle = 2 * math.pi;
final controlPoints = [ final controlPoints = [
Vector2(0, 0), Vector2(0, 0),
Vector2(10, 0), Vector2(10, 0),
@ -16,12 +13,25 @@ void main() {
Vector2(10, 10), Vector2(10, 10),
]; ];
test('can be instantiated', () {
expect(
BezierCurveShape(
controlPoints: controlPoints,
),
isNotNull,
);
});
test('returns vertices rotated', () {
const rotationAngle = 2 * math.pi;
final bezierCurveShape = BezierCurveShape( final bezierCurveShape = BezierCurveShape(
controlPoints: controlPoints, controlPoints: controlPoints,
); );
final bezierCurveShapeRotated = BezierCurveShape( final bezierCurveShapeRotated = BezierCurveShape(
controlPoints: controlPoints, controlPoints: controlPoints,
)..rotate(rotationAngle); rotation: rotationAngle,
);
for (var index = 0; index < bezierCurveShape.vertices.length; index++) { for (var index = 0; index < bezierCurveShape.vertices.length; index++) {
expect( expect(
@ -31,5 +41,4 @@ void main() {
} }
}); });
}); });
});
} }

@ -6,7 +6,17 @@ import 'package:pinball_components/src/components/components.dart';
void main() { void main() {
group('EllipseShape', () { group('EllipseShape', () {
group('rotate', () { test('can be instantiated', () {
expect(
EllipseShape(
center: Vector2.zero(),
majorRadius: 10,
minorRadius: 8,
),
isNotNull,
);
});
test('returns vertices rotated', () { test('returns vertices rotated', () {
const rotationAngle = 2 * math.pi; const rotationAngle = 2 * math.pi;
final ellipseShape = EllipseShape( final ellipseShape = EllipseShape(
@ -18,7 +28,8 @@ void main() {
center: Vector2.zero(), center: Vector2.zero(),
majorRadius: 10, majorRadius: 10,
minorRadius: 8, minorRadius: 8,
)..rotate(rotationAngle); rotation: rotationAngle,
);
for (var index = 0; index < ellipseShape.vertices.length; index++) { for (var index = 0; index < ellipseShape.vertices.length; index++) {
expect( expect(
@ -27,7 +38,6 @@ void main() {
); );
} }
}); });
});
group('copyWith', () { group('copyWith', () {
test('returns same shape when no properties are passed', () { test('returns same shape when no properties are passed', () {

Loading…
Cancel
Save