flutter-ci / test (push) Canceled after 0s
- Drama 新增 coverLandscape,WatchProgress 新增 dramaCoverLandscape - 继续观看横幅优先使用横版封面,缺省回退竖版 - 底部导航栏图标与文字间距由 5dp 收紧至 1dp
93 lines
2.6 KiB
Dart
93 lines
2.6 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',
|
|
'likeCount': '18',
|
|
'commentCount': 4,
|
|
},
|
|
});
|
|
|
|
expect(drama.detailLoaded, isFalse);
|
|
expect(drama.episodes, hasLength(1));
|
|
expect(drama.episodes.single.videoUrl, '/files/episode/9.mp4');
|
|
expect(drama.episodes.single.likeCount, 18);
|
|
expect(drama.episodes.single.commentCount, 4);
|
|
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_parse_landscape_cover_for_horizontal_slots', () {
|
|
final card = Drama.fromCardJson(const {
|
|
'id': 5,
|
|
'title': '闪婚后',
|
|
'cover': '/files/cover.jpg',
|
|
'coverLandscape': '/files/cover-wide.jpg',
|
|
});
|
|
final legacy = Drama.fromDetailJson(const {
|
|
'id': 6,
|
|
'title': '替嫁新娘',
|
|
'cover': '/files/cover-2.jpg',
|
|
});
|
|
|
|
expect(card.coverLandscape, '/files/cover-wide.jpg');
|
|
expect(legacy.coverLandscape, isEmpty);
|
|
});
|
|
|
|
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,
|
|
'likeCount': '21',
|
|
'commentCount': '6',
|
|
},
|
|
{'id': 10, 'number': 2, 'title': '第 2 集', 'isFree': false},
|
|
],
|
|
});
|
|
|
|
expect(drama.detailLoaded, isTrue);
|
|
expect(drama.episodeCount, 77);
|
|
expect(drama.episodes.first.id, '9');
|
|
expect(drama.episodes.first.likeCount, 21);
|
|
expect(drama.episodes.first.commentCount, 6);
|
|
});
|
|
}
|