feat: added test for exported json
This commit is contained in:
@@ -102,36 +102,6 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"teams": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"id": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"name": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"createdAt": {
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"memberIds": {
|
|
||||||
"type": "array",
|
|
||||||
"items": {
|
|
||||||
"type": "string"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"additionalProperties": false,
|
|
||||||
"required": [
|
|
||||||
"id",
|
|
||||||
"name",
|
|
||||||
"createdAt",
|
|
||||||
"memberIds"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"matches": {
|
"matches": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
@@ -195,6 +165,9 @@
|
|||||||
},
|
},
|
||||||
"notes": {
|
"notes": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"teams": {
|
||||||
|
"type": ["array", "null"]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
@@ -214,7 +187,6 @@
|
|||||||
"players",
|
"players",
|
||||||
"games",
|
"games",
|
||||||
"groups",
|
"groups",
|
||||||
"teams",
|
|
||||||
"matches"
|
"matches"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -137,9 +137,6 @@ void main() {
|
|||||||
await database.playerDao.addPlayer(player: testPlayer2);
|
await database.playerDao.addPlayer(player: testPlayer2);
|
||||||
await database.gameDao.addGame(game: testGame);
|
await database.gameDao.addGame(game: testGame);
|
||||||
await database.groupDao.addGroup(group: testGroup);
|
await database.groupDao.addGroup(group: testGroup);
|
||||||
/*
|
|
||||||
await database.teamDao.addTeam(team: testTeam);
|
|
||||||
*/
|
|
||||||
await database.matchDao.addMatch(match: testMatch);
|
await database.matchDao.addMatch(match: testMatch);
|
||||||
|
|
||||||
final ctx = await getContext(tester);
|
final ctx = await getContext(tester);
|
||||||
@@ -853,7 +850,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test('validateJsonSchema()', () async {
|
test('validateJsonSchema() works correctly', () async {
|
||||||
final validJson = json.encode({
|
final validJson = json.encode({
|
||||||
'players': [
|
'players': [
|
||||||
{
|
{
|
||||||
@@ -912,5 +909,23 @@ void main() {
|
|||||||
final isValid = await DataTransferService.validateJsonSchema(validJson);
|
final isValid = await DataTransferService.validateJsonSchema(validJson);
|
||||||
expect(isValid, true);
|
expect(isValid, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('validateJsonSchema() validates exported json file', (
|
||||||
|
tester,
|
||||||
|
) async {
|
||||||
|
await database.playerDao.addPlayer(player: testPlayer1);
|
||||||
|
await database.playerDao.addPlayer(player: testPlayer2);
|
||||||
|
await database.gameDao.addGame(game: testGame);
|
||||||
|
await database.groupDao.addGroup(group: testGroup);
|
||||||
|
await database.matchDao.addMatch(match: testMatch);
|
||||||
|
|
||||||
|
final ctx = await getContext(tester);
|
||||||
|
final jsonString = await DataTransferService.getAppDataAsJson(ctx);
|
||||||
|
|
||||||
|
expect(jsonString, isNotEmpty);
|
||||||
|
|
||||||
|
final isValid = await DataTransferService.validateJsonSchema(jsonString);
|
||||||
|
expect(isValid, true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user