Files
BlockSeasons/test/ui/map_layout_test.dart

33 lines
1.0 KiB
Dart

import 'package:block_seasons/ui/widgets/map_layout.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
const layout = MapLayout(width: 400);
test('node 0 sits near the bottom, later nodes climb', () {
final h = layout.heightFor(60);
final first = layout.nodeCenter(0, 60);
final last = layout.nodeCenter(59, 60);
expect(first.dy, greaterThan(h - 200));
expect(last.dy, lessThan(200));
for (var i = 1; i < 60; i++) {
expect(layout.nodeCenter(i, 60).dy,
lessThan(layout.nodeCenter(i - 1, 60).dy));
}
});
test('x stays within horizontal margins', () {
for (var i = 0; i < 60; i++) {
final x = layout.nodeCenter(i, 60).dx;
expect(x, greaterThanOrEqualTo(400 * 0.12));
expect(x, lessThanOrEqualTo(400 * 0.88));
}
});
test('vertical spacing is uniform', () {
final a = layout.nodeCenter(3, 60).dy - layout.nodeCenter(4, 60).dy;
final b = layout.nodeCenter(40, 60).dy - layout.nodeCenter(41, 60).dy;
expect(a, closeTo(b, 0.001));
});
}