为什么:红线第 8 条门禁立即生效,要求 Flutter 测试命名合规;此前 155 条用例名是英文自然语言 或中文描述,合规数 0/155,属存量欠账,按"先补齐再上新功能"在本批处理。 - 25 个测试文件、155 条用例改名,按「文件 + 旧名」精确定位,每条断言命中恰好 1 次才替换 - 只改名字字面量:改动行 155 删 + 155 增,无一行不含字符串字面量(断言与用例体零改动) - 门禁:dart analyze lib test = No issues found;flutter test = 155 全过
61 lines
1.7 KiB
Dart
61 lines
1.7 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:nontonki/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,
|
|
'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);
|
|
});
|
|
|
|
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');
|
|
});
|
|
}
|