diff --git a/test/models/schema_test.dart b/test/models/schema_test.dart index f9f6f96..3267bca 100644 --- a/test/models/schema_test.dart +++ b/test/models/schema_test.dart @@ -7,15 +7,15 @@ void main() { setUp(() { s1 = Schema( - 'companies', - { - Field('company_name', type: Type.string), - Field('num_employees', type: Type.int32), - Field('country', type: Type.string, isFacetable: true), - }, - defaultSortingField: Field('num_employees'), - documentCount: 0, - ); + 'companies', + { + Field('company_name', type: Type.string), + Field('num_employees', type: Type.int32), + Field('country', type: Type.string, isFacetable: true), + }, + defaultSortingField: Field('num_employees'), + documentCount: 0, + enableNestedFields: true); s2 = Schema.fromMap({ "name": "companies", "fields": [ @@ -25,6 +25,7 @@ void main() { ], "default_sorting_field": "num_employees", "num_documents": 0, + "enable_nested_fields": true, }); }); @@ -54,6 +55,10 @@ void main() { expect(s2.defaultSortingField, equals(Field('num_employees', type: Type.int32))); }); + test('has a enableNestedFields field', () { + expect(s1.enableNestedFields, equals(true)); + expect(s2.enableNestedFields, equals(true)); + }); test('has a toMap method', () { final map = { "name": "companies", @@ -64,6 +69,7 @@ void main() { ], "default_sorting_field": "num_employees", "num_documents": 0, + "enable_nested_fields": true, }; expect(s1.toMap(), equals(map)); @@ -151,6 +157,32 @@ void main() { ), ); }); + test("with null/empty enableNestedFields is successful", () { + var schema = Schema.fromMap({ + "name": "companies", + "fields": [ + {"name": "company_name", "type": "string"}, + {"name": "num_employees", "type": "int32"}, + {"name": "country", "type": "string", "facet": true} + ], + "default_sorting_field": "", + "num_documents": 0, + }); + expect(schema.name, equals('companies')); + expect(schema.enableNestedFields, isNull); + + schema = Schema.fromMap({ + "name": "companies", + "fields": [ + {"name": "company_name", "type": "string"}, + {"name": "num_employees", "type": "int32"}, + {"name": "country", "type": "string", "facet": true} + ], + "num_documents": 0, + }); + expect(schema.name, equals('companies')); + expect(schema.enableNestedFields, isNull); + }); }); group('UpdateSchema', () {