Files
ReelShort/test/playback/video_player_port_test.dart
T
Vicky 0e5d550b50 test(client): 用例名统一为 should_<期望>_when_<条件>(155/155)
为什么:红线第 8 条门禁立即生效,要求 Flutter 测试命名合规;此前 155 条用例名是英文自然语言
或中文描述,合规数 0/155,属存量欠账,按"先补齐再上新功能"在本批处理。

- 25 个测试文件、155 条用例改名,按「文件 + 旧名」精确定位,每条断言命中恰好 1 次才替换
- 只改名字字面量:改动行 155 删 + 155 增,无一行不含字符串字面量(断言与用例体零改动)
- 门禁:dart analyze lib test = No issues found;flutter test = 155 全过
2026-10-16 09:41:14 +08:00

38 lines
1.2 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter_test/flutter_test.dart';
import 'package:nontonki/core/config/app_config.dart';
import 'package:nontonki/core/data/models/drama.dart';
import 'package:nontonki/core/data/services/video_player_port.dart';
Episode _episode(String videoUrl) => Episode(
id: '1',
number: 1,
title: '第 1 集',
isFree: true,
videoUrl: videoUrl,
);
void main() {
test('should_prefix_service_base_when_play_url_is_relative', () {
final uri = VideoPlayerPort.resolveUri(
_episode('/files/episode/202610/clip.mp4'),
);
expect(uri.isAbsolute, isTrue);
// Uri.parse().toString() 会把 host 规范成小写,而 devHostBaseUrl 里的
// Bonjour 名字带大写(jiangdeMacBook-Air.local)—— 比较时统一小写,
// 否则会依赖运行平台(flutter test 里 defaultTargetPlatform 默认是 android)
expect(
uri.toString().toLowerCase(),
'${AppConfig.apiBaseUrl}/files/episode/202610/clip.mp4'.toLowerCase(),
);
});
test('should_keep_url_untouched_when_play_url_is_absolute', () {
final uri = VideoPlayerPort.resolveUri(
_episode('https://cdn.example.test/clip.mp4'),
);
expect(uri.toString(), 'https://cdn.example.test/clip.mp4');
});
}