commit
9c5fef1a4d
412 files changed
+94582
No files matched your search
@@ -0,0 +1,63 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:sakura_mobile/src/core/api_client.dart';
|
||||
import 'package:sakura_mobile/src/core/legado_models.dart';
|
||||
|
||||
void main() {
|
||||
group('在线解析兜底', () {
|
||||
test('云端小说解析结果可以转为可阅读章节', () {
|
||||
final parsed = OnlineParsedContent.fromJson({
|
||||
'title': '龙族',
|
||||
'kind': 'novel',
|
||||
'cover': 'https://example.com/cover.jpg',
|
||||
'chapters': [
|
||||
{
|
||||
'name': '第一章',
|
||||
'url': 'https://example.com/read/1.html',
|
||||
'content': '路明非站在雨里,故事从这里开始。',
|
||||
'images': [],
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
final chapter = OnlineChapter(
|
||||
title: parsed.chapters.first.name,
|
||||
url: parsed.chapters.first.url!,
|
||||
index: 1,
|
||||
);
|
||||
final content = OnlineChapterContent(
|
||||
title: chapter.title,
|
||||
textContent: parsed.chapters.first.content,
|
||||
);
|
||||
|
||||
expect(parsed.title, '龙族');
|
||||
expect(chapter.url, 'https://example.com/read/1.html');
|
||||
expect(content.textContent, contains('路明非'));
|
||||
});
|
||||
|
||||
test('云端漫画解析结果可以转为图片章节', () {
|
||||
final parsed = OnlineParsedContent.fromJson({
|
||||
'title': '一人之下',
|
||||
'kind': 'manga',
|
||||
'chapters': [
|
||||
{
|
||||
'name': '第1话',
|
||||
'url': 'https://example.com/comic/1',
|
||||
'images': [
|
||||
'https://example.com/001.webp',
|
||||
'https://example.com/002.webp',
|
||||
],
|
||||
}
|
||||
],
|
||||
});
|
||||
|
||||
final content = OnlineChapterContent(
|
||||
title: parsed.chapters.first.name,
|
||||
imageUrls: parsed.chapters.first.images,
|
||||
);
|
||||
|
||||
expect(parsed.title, '一人之下');
|
||||
expect(content.imageUrls, hasLength(2));
|
||||
expect(content.imageUrls.first, endsWith('001.webp'));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user