39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
// 分享文案单测:标题/标签/链接组合
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:video_app/core/utils/share_text.dart';
|
|
import 'package:video_app/models/video_item.dart';
|
|
|
|
void main() {
|
|
group('buildShareText', () {
|
|
test('标题 + 标签 + 可用链接', () {
|
|
final item = VideoItem(
|
|
videoId: 1,
|
|
author: VideoAuthor(userId: 1),
|
|
title: '海边日落',
|
|
tags: const ['旅行', '日落'],
|
|
videoUrl: 'https://cdn.example.com/hls/1/index.m3u8',
|
|
);
|
|
expect(
|
|
buildShareText(item),
|
|
'「海边日落」 #旅行 #日落\nhttps://cdn.example.com/hls/1/index.m3u8',
|
|
);
|
|
});
|
|
|
|
test('链接不可用时省略链接行', () {
|
|
final item = VideoItem(
|
|
videoId: 1,
|
|
author: VideoAuthor(userId: 1),
|
|
title: '海边日落',
|
|
videoUrl: '/hls/1/index.m3u8',
|
|
);
|
|
expect(buildShareText(item, testUrl: ''), '「海边日落」');
|
|
});
|
|
|
|
test('空标题用兜底文案', () {
|
|
final item = VideoItem(videoId: 1, author: VideoAuthor(userId: 1));
|
|
expect(buildShareText(item, testUrl: ''), '精彩视频');
|
|
});
|
|
});
|
|
}
|