63 lines
1.8 KiB
Dart
63 lines
1.8 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fruitshorts/core/data/models/drama.dart';
|
|
|
|
void main() {
|
|
test('should_carry_one_preview_and_total_count_when_list_card_is_parsed', () {
|
|
final drama = Drama.fromCardJson(const {
|
|
'id': 5,
|
|
'title': '闪婚后',
|
|
'synopsis': 'synopsis',
|
|
'cover': '/files/cover.jpg',
|
|
'category': '都市情感',
|
|
'genre': '都市情感',
|
|
'totalEpisodes': 77,
|
|
'isHot': true,
|
|
'viewCount': 3100000,
|
|
'language': 'zh-CN',
|
|
'preview': {
|
|
'id': 9,
|
|
'number': 1,
|
|
'title': '第 1 集',
|
|
'isFree': true,
|
|
'playUrl': '/files/episode/9.mp4',
|
|
},
|
|
});
|
|
|
|
expect(drama.detailLoaded, isFalse);
|
|
expect(drama.episodes, hasLength(1));
|
|
expect(drama.episodes.single.videoUrl, '/files/episode/9.mp4');
|
|
expect(drama.episodeCount, 77);
|
|
expect(drama.isHot, isTrue);
|
|
expect(drama.language, 'zh-CN');
|
|
});
|
|
|
|
test('should_have_no_episodes_when_list_card_has_no_playable_preview', () {
|
|
final drama = Drama.fromCardJson(const {
|
|
'id': 6,
|
|
'title': '替嫁新娘',
|
|
'totalEpisodes': 12,
|
|
});
|
|
|
|
expect(drama.episodes, isEmpty);
|
|
expect(drama.episodeCount, 12);
|
|
});
|
|
|
|
test('should_count_shipped_episodes_when_detail_response_is_parsed', () {
|
|
final drama = Drama.fromDetailJson(const {
|
|
'id': 5,
|
|
'title': '闪婚后',
|
|
'synopsis': 'synopsis',
|
|
'cover': '/files/cover.jpg',
|
|
'totalEpisodes': 77,
|
|
'episodes': [
|
|
{'id': 9, 'number': 1, 'title': '第 1 集', 'isFree': true},
|
|
{'id': 10, 'number': 2, 'title': '第 2 集', 'isFree': false},
|
|
],
|
|
});
|
|
|
|
expect(drama.detailLoaded, isTrue);
|
|
expect(drama.episodeCount, 77);
|
|
expect(drama.episodes.first.id, '9');
|
|
});
|
|
}
|