From 323ad807bd661321a7c446ccf002e34993090bb3 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Fri, 9 Mar 2018 07:43:17 -0500 Subject: [PATCH] Test `Fields` class --- angel_serialize_generator/test/book_test.dart | 6 ++++++ angel_serialize_generator/test/models/book.dart | 3 +++ angel_serialize_generator/test/models/book.g.dart | 6 ++++++ .../test/models/book.serializer.g.dart | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/angel_serialize_generator/test/book_test.dart b/angel_serialize_generator/test/book_test.dart index a9f03091..5f288145 100644 --- a/angel_serialize_generator/test/book_test.dart +++ b/angel_serialize_generator/test/book_test.dart @@ -79,6 +79,12 @@ main() { }); }); + test('fields', () { + expect(BookFields.author, 'author'); + expect(BookFields.notModels, 'not_models'); + expect(BookFields.camelCaseString, 'camelCase'); + }); + group('deserialization', () { test('deserialization sets proper fields', () { var book = BookSerializer.fromMap(deathlyHallowsMap); diff --git a/angel_serialize_generator/test/models/book.dart b/angel_serialize_generator/test/models/book.dart index 92dc0319..74381a70 100644 --- a/angel_serialize_generator/test/models/book.dart +++ b/angel_serialize_generator/test/models/book.dart @@ -10,4 +10,7 @@ abstract class _Book extends Model { String author, title, description; int pageCount; List notModels; + + @Alias('camelCase') + String camelCaseString; } \ No newline at end of file diff --git a/angel_serialize_generator/test/models/book.g.dart b/angel_serialize_generator/test/models/book.g.dart index 7140019e..1ea39166 100644 --- a/angel_serialize_generator/test/models/book.g.dart +++ b/angel_serialize_generator/test/models/book.g.dart @@ -14,6 +14,7 @@ class Book extends _Book { this.description, this.pageCount, this.notModels, + this.camelCaseString, this.createdAt, this.updatedAt}); @@ -35,6 +36,9 @@ class Book extends _Book { @override final List notModels; + @override + final String camelCaseString; + @override final DateTime createdAt; @@ -48,6 +52,7 @@ class Book extends _Book { String description, int pageCount, List notModels, + String camelCaseString, DateTime createdAt, DateTime updatedAt}) { return new Book( @@ -57,6 +62,7 @@ class Book extends _Book { description: description ?? this.description, pageCount: pageCount ?? this.pageCount, notModels: notModels ?? this.notModels, + camelCaseString: camelCaseString ?? this.camelCaseString, createdAt: createdAt ?? this.createdAt, updatedAt: updatedAt ?? this.updatedAt); } diff --git a/angel_serialize_generator/test/models/book.serializer.g.dart b/angel_serialize_generator/test/models/book.serializer.g.dart index 52c1c642..33ede5ba 100644 --- a/angel_serialize_generator/test/models/book.serializer.g.dart +++ b/angel_serialize_generator/test/models/book.serializer.g.dart @@ -14,6 +14,7 @@ abstract class BookSerializer { String description, int pageCount, List notModels, + String camelCaseString, DateTime createdAt, DateTime updatedAt}) { return new Book( @@ -23,6 +24,7 @@ abstract class BookSerializer { description: map['description'], pageCount: map['page_count'], notModels: map['not_models'], + camelCaseString: map['camelCase'], createdAt: map['created_at'] != null ? DateTime.parse(map['created_at']) : null, @@ -39,6 +41,7 @@ abstract class BookSerializer { 'description': model.description, 'page_count': model.pageCount, 'not_models': model.notModels, + 'camelCase': model.camelCaseString, 'created_at': model.createdAt?.toIso8601String(), 'updated_at': model.updatedAt?.toIso8601String() }; @@ -58,6 +61,8 @@ abstract class BookFields { static const String notModels = 'not_models'; + static const String camelCaseString = 'camelCase'; + static const String createdAt = 'created_at'; static const String updatedAt = 'updated_at';