diff --git a/test/services/data_transfer_service_test.dart b/test/services/data_transfer_service_test.dart index bfbb09f..575e52f 100644 --- a/test/services/data_transfer_service_test.dart +++ b/test/services/data_transfer_service_test.dart @@ -588,6 +588,18 @@ void main() { expect(games[0].ruleset, testGame.ruleset); }); + test('parseGamesFromJson() empty list', () { + final jsonMap = {'games': []}; + final games = DataTransferService.parseGamesFromJson(jsonMap); + expect(games, isEmpty); + }); + + test('parseGamesFromJson() missing key', () { + final jsonMap = {}; + final games = DataTransferService.parseGamesFromJson(jsonMap); + expect(games, isEmpty); + }); + test('parseGroupsFromJson()', () { final playerById = { testPlayer1.id: testPlayer1, @@ -619,6 +631,18 @@ void main() { expect(groups[0].members[1].id, testPlayer2.id); }); + test('parseGroupsFromJson() empty list', () { + final jsonMap = {'groups': []}; + final groups = DataTransferService.parseGroupsFromJson(jsonMap, {}); + expect(groups, isEmpty); + }); + + test('parseGroupsFromJson() missing key', () { + final jsonMap = {}; + final groups = DataTransferService.parseGroupsFromJson(jsonMap, {}); + expect(groups, isEmpty); + }); + test('parseGroupsFromJson() ignores invalid player ids', () { final playerById = {testPlayer1.id: testPlayer1}; @@ -670,6 +694,18 @@ void main() { expect(teams[0].members[0].id, testPlayer1.id); }); + test('parseTeamsFromJson() empty list', () { + final jsonMap = {'teams': []}; + final teams = DataTransferService.parseTeamsFromJson(jsonMap, {}); + expect(teams, isEmpty); + }); + + test('parseTeamsFromJson() missing key', () { + final jsonMap = {}; + final teams = DataTransferService.parseTeamsFromJson(jsonMap, {}); + expect(teams, isEmpty); + }); + test('parseMatchesFromJson()', () { final playerById = { testPlayer1.id: testPlayer1, @@ -707,6 +743,28 @@ void main() { expect(matches[0].players.length, 2); }); + test('parseMatchesFromJson() empty list', () { + final jsonMap = {'teams': []}; + final matches = DataTransferService.parseMatchesFromJson( + jsonMap, + {}, + {}, + {}, + ); + expect(matches, isEmpty); + }); + + test('parseMatchesFromJson() missing key', () { + final jsonMap = {}; + final matches = DataTransferService.parseMatchesFromJson( + jsonMap, + {}, + {}, + {}, + ); + expect(matches, isEmpty); + }); + test('parseMatchesFromJson() creates unknown game for missing game', () { final playerById = {testPlayer1.id: testPlayer1}; final gameById = {};