workouttest_util/test/app_text_test.dart
2023-03-19 09:51:05 +01:00

116 lines
2.0 KiB
Dart

import 'dart:convert';
import 'package:flutter_test/flutter_test.dart';
import 'package:workouttest_util/model/app_text.dart';
main() {
late String appTextJson;
setUp(() {
appTextJson = '''
[
{
"textId": 1,
"textKey": "monday",
"screenshotUrl": null,
"checked": false,
"translations": [
{
"translationId": 1,
"languageCode": "hu",
"translation": "hétfő"
}
]
},
{
"textId": 2,
"textKey": "tuesday",
"screenshotUrl": null,
"checked": false,
"translations": [
{
"translationId": 2,
"languageCode": "hu",
"translation": "kedd"
}
]
},
{
"textId": 3,
"textKey": "wednesday",
"screenshotUrl": null,
"checked": false,
"translations": [
{
"translationId": 3,
"languageCode": "hu",
"translation": "szerda"
}
]
},
{
"textId": 4,
"textKey": "thursday",
"screenshotUrl": null,
"checked": false,
"translations": [
{
"translationId": 4,
"languageCode": "hu",
"translation": "csütörtök"
}
]
},
{
"textId": 5,
"textKey": "friday",
"screenshotUrl": null,
"checked": false,
"translations": [
{
"translationId": 5,
"languageCode": "hu",
"translation": "péntek"
}
]
},
{
"textId": 6,
"textKey": "saturday",
"screenshotUrl": null,
"checked": false,
"translations": [
{
"translationId": 6,
"languageCode": "hu",
"translation": "szombat"
}
]
},
{
"textId": 7,
"textKey": "sunday",
"screenshotUrl": null,
"checked": false,
"translations": [
{
"translationId": 7,
"languageCode": "hu",
"translation": "vasárnap"
}
]
}
]
''';
});
group('customer', () {
test('decode from json successful', () async {
Iterable json = jsonDecode(appTextJson);
final List<AppText> appTexts = json.map((text) => AppText.fromJson(text)).toList();
expect(appTexts[0].textKey, "monday");
expect(appTexts[1].translations['hu'], "kedd");
print(appTexts[0]);
});
});
}