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": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@@ -195,6 +165,9 @@
|
||||
},
|
||||
"notes": {
|
||||
"type": "string"
|
||||
},
|
||||
"teams": {
|
||||
"type": ["array", "null"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
@@ -214,7 +187,6 @@
|
||||
"players",
|
||||
"games",
|
||||
"groups",
|
||||
"teams",
|
||||
"matches"
|
||||
]
|
||||
}
|
||||
@@ -137,9 +137,6 @@ void main() {
|
||||
await database.playerDao.addPlayer(player: testPlayer2);
|
||||
await database.gameDao.addGame(game: testGame);
|
||||
await database.groupDao.addGroup(group: testGroup);
|
||||
/*
|
||||
await database.teamDao.addTeam(team: testTeam);
|
||||
*/
|
||||
await database.matchDao.addMatch(match: testMatch);
|
||||
|
||||
final ctx = await getContext(tester);
|
||||
@@ -853,7 +850,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
test('validateJsonSchema()', () async {
|
||||
test('validateJsonSchema() works correctly', () async {
|
||||
final validJson = json.encode({
|
||||
'players': [
|
||||
{
|
||||
@@ -912,5 +909,23 @@ void main() {
|
||||
final isValid = await DataTransferService.validateJsonSchema(validJson);
|
||||
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