import 'package:flutter_test/flutter_test.dart'; import 'package:match_three/game/models/gem.dart'; import 'package:match_three/game/models/grid.dart'; import 'package:match_three/game/systems/match_detector.dart'; void main() { group('Match Three Game Tests', () { test('Grid initialization creates 8x8 grid', () { final grid = GameGrid(width: 8, height: 8); for (int row = 0; row < 8; row++) { for (int col = 0; col < 8; col++) { expect(grid.getGem(row, col), isNotNull); } } }); test('Grid initialization creates custom size grid', () { final grid = GameGrid(width: 5, height: 5); for (int row = 0; row < 5; row++) { for (int col = 0; col < 5; col++) { expect(grid.getGem(row, col), isNotNull); } } // Test that positions outside the grid return null expect(grid.getGem(5, 0), isNull); expect(grid.getGem(0, 5), isNull); }); test('Match detector validates adjacent positions', () { final grid = GameGrid(width: 8, height: 8); // Test adjacent positions (should be valid) expect(MatchDetector.isValidSwap(grid, 0, 0, 0, 1), isTrue); expect(MatchDetector.isValidSwap(grid, 0, 0, 1, 0), isTrue); // Test non-adjacent positions (should be invalid) expect(MatchDetector.isValidSwap(grid, 0, 0, 0, 2), isFalse); expect(MatchDetector.isValidSwap(grid, 0, 0, 2, 0), isFalse); }); test('Gem creation with correct properties', () { final gem = Gem(type: 1, row: 2, col: 3); expect(gem.type, equals(1)); expect(gem.row, equals(2)); expect(gem.col, equals(3)); expect(gem.isMatched, isFalse); expect(gem.isSpecial, isFalse); }); }); }