Tests for enum type conversion from mirror
This commit is contained in:
parent
79ffc00fb1
commit
01e3b067de
2 changed files with 5 additions and 0 deletions
|
@ -24,6 +24,7 @@ class GraphQLEnumType<Value> extends GraphQLScalarType<Value, String>
|
|||
|
||||
@override
|
||||
String serialize(Value value) {
|
||||
if (value == null) return null;
|
||||
return values.firstWhere((v) => v.value == value).name;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,10 @@ void main() {
|
|||
expect(asEnumType.serialize(RomanceLanguage.FRANCE), 'FRANCE');
|
||||
});
|
||||
|
||||
test('can serialize null', () {
|
||||
expect(asEnumType.serialize(null), null);
|
||||
});
|
||||
|
||||
test('fails to serialize invalid value', () {
|
||||
expect(() => asEnumType.serialize(34), throwsStateError);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue