Skip to content

Commit

Permalink
#130: added extra test to model reader
Browse files Browse the repository at this point in the history
  • Loading branch information
jorre127 committed Sep 8, 2023
1 parent a78c87b commit 534d60c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/writer/model_reader_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ TestModel:
expect(error, isNotNull);
expect(error, isArgumentError);
if (error is ArgumentError) {
expect(error.message,
'required is removed, follow the migration to version 7.0.0');
expect(error.message, 'required is removed, follow the migration to version 7.0.0');
}
});

Expand All @@ -121,8 +120,7 @@ TestModel:
expect(error, isNotNull);
expect(error, isException);
if (error is Exception) {
expect(error.toString(),
'Exception: Could not generate all models. `array` is not added to the config file');
expect(error.toString(), 'Exception: Could not generate all models. `array` is not added to the config file');
}
});

Expand All @@ -149,8 +147,7 @@ TestModel:
expect(error, isNotNull);
expect(error, isException);
if (error is Exception) {
expect(error.toString(),
'Exception: Could not generate all models. `map` is not added to the config file');
expect(error.toString(), 'Exception: Could not generate all models. `map` is not added to the config file');
}
});

Expand All @@ -164,6 +161,7 @@ TestModel:
simpleStringList: List<string>
nullableStringList: List<string>?
simpleMap: Map<String, int>
nestedMap: Map<String, List<int>>
""",
'');
final models = config.models;
Expand All @@ -181,6 +179,7 @@ TestModel:
final simpleStringList = model.fields.getByName("simpleStringList");
final nullableStringList = model.fields.getByName("nullableStringList");
final simpleMap = model.fields.getByName("simpleMap");
final nestedMap = model.fields.getByName("nestedMap");

expect(simpleStringList.type, isA<ArrayType>());
expect(simpleStringList.isRequired, true);
Expand All @@ -191,6 +190,13 @@ TestModel:
expect(simpleMap.type, isA<MapType>());
expect(simpleMap.isRequired, true);

expect(nestedMap.type, isA<MapType>());
if (nestedMap.type is MapType) {
final type = nestedMap.type as MapType;
expect(type.valueName, 'List<int>');
}
expect(nestedMap.isRequired, true);

expect(error, isNull);
});
test('Test simple object reference fields', () {
Expand Down

0 comments on commit 534d60c

Please sign in to comment.