Skip to content

Commit 1f3be22

Browse files
committed
fix: tests
1 parent ea2ee0a commit 1f3be22

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

lib/src/controller.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,10 +259,6 @@ class SimpleMapController {
259259
/// based on the [size].
260260
///
261261
void render(Canvas canvas, Size size) {
262-
if (_state == null) {
263-
throw Exception('Please use `controller.configure` before render.');
264-
}
265-
266262
var delta = 0.0;
267263
if (_animation != null) {
268264
final _newLastTimeMs =

test/controller_test.dart

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import 'package:flutter_test/flutter_test.dart';
33
import 'package:mockito/mockito.dart';
44
import 'package:simple_map/simple_map.dart';
55

6-
class MockCanvas extends Mock implements Canvas {}
6+
class MockCanvas extends Mock implements Canvas {
7+
@override
8+
void drawCircle(Offset? c, double? radius, Paint? paint) {
9+
super.noSuchMethod(Invocation.method(#drawCircle, [c, radius, paint]));
10+
}
11+
}
712

813
void main() {
914
final animation = AnimationController(
@@ -25,21 +30,26 @@ void main() {
2530
});
2631

2732
test('test render', () async {
28-
final controller = SimpleMapController(points: [
29-
SimpleMapPoint(
30-
lat: 0,
31-
lng: 0,
32-
color: Color(0xFFFFFFFF),
33-
)
34-
]);
33+
final controller = SimpleMapController(
34+
points: [
35+
SimpleMapPoint(
36+
lat: 0,
37+
lng: 0,
38+
color: Color(0xFFFFFFFF),
39+
)
40+
],
41+
);
3542

36-
Canvas canvas = MockCanvas();
37-
Size size = Size(100, 100);
43+
final canvas = MockCanvas();
44+
final size = Size.square(100);
3845

39-
controller.configure(options: options, animation: animation);
46+
controller.configure(
47+
options: options,
48+
animation: animation,
49+
);
4050

4151
controller.render(canvas, size);
42-
verify(canvas.drawCircle(Offset.zero, 0, Paint())).called(2);
52+
verify(canvas.drawCircle(any, any, any)).called(2);
4353

4454
controller.addPoint(
4555
SimpleMapPoint(
@@ -51,6 +61,6 @@ void main() {
5161
);
5262

5363
controller.render(canvas, size);
54-
verify(canvas.drawCircle(Offset.zero, 0, Paint())).called(3);
64+
verify(canvas.drawCircle(any, any, any)).called(3);
5565
});
5666
}

0 commit comments

Comments
 (0)