forked from eatvio/eatvio_app
feat(tests): updated tests coverage to 66.5%
This commit is contained in:
@@ -179,5 +179,74 @@ void main() {
|
||||
expect(sub.name, 'User One');
|
||||
expect(sub.isEntitySubscribedByMe, true);
|
||||
});
|
||||
|
||||
test('toJson serializes SubModel correctly', () {
|
||||
final sub = SubModel(
|
||||
slug: 'user1',
|
||||
name: 'User One',
|
||||
city: 'New York',
|
||||
birthdate: DateTime(1990, 1, 1),
|
||||
isEntitySubscribedByMe: true,
|
||||
profilePhotoUrl: 'photo1.jpg',
|
||||
roles: ['consultant'],
|
||||
);
|
||||
|
||||
final json = sub.toJson();
|
||||
|
||||
expect(json['slug'], 'user1');
|
||||
expect(json['name'], 'User One');
|
||||
expect(json['city'], 'New York');
|
||||
expect(json['is_entity_subscribed_by_me'], isTrue);
|
||||
expect(json['profile_photo_url'], 'photo1.jpg');
|
||||
expect(json['roles'], ['consultant']);
|
||||
expect(json.containsKey('birthdate'), isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
group('SubPaginationModel', () {
|
||||
test('toJson serializes SubPaginationModel correctly', () {
|
||||
final subs = [
|
||||
SubModel(
|
||||
slug: 'user1',
|
||||
name: 'User One',
|
||||
city: 'New York',
|
||||
birthdate: DateTime(1990, 1, 1),
|
||||
isEntitySubscribedByMe: true,
|
||||
profilePhotoUrl: 'photo1.jpg',
|
||||
roles: ['consultant'],
|
||||
),
|
||||
];
|
||||
|
||||
const links = Links(
|
||||
first: 'http://example.com?page=1',
|
||||
last: 'http://example.com?page=1',
|
||||
prev: null,
|
||||
next: null,
|
||||
);
|
||||
|
||||
const meta = Meta(
|
||||
currentPage: 1,
|
||||
from: 1,
|
||||
lastPage: 1,
|
||||
links: [],
|
||||
path: '/api/subs',
|
||||
perPage: 10,
|
||||
to: 1,
|
||||
total: 1,
|
||||
);
|
||||
|
||||
final model = SubPaginationModel(
|
||||
data: subs,
|
||||
links: links,
|
||||
meta: meta,
|
||||
);
|
||||
|
||||
final json = model.toJson();
|
||||
|
||||
expect(json.containsKey('data'), isTrue);
|
||||
expect((json['data'] as List).length, 1);
|
||||
expect(json.containsKey('links'), isTrue);
|
||||
expect(json.containsKey('meta'), isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user