feat(app): 剧场列表增加语种筛选
This commit is contained in:
1 parent
ade0cc3566
commit
30a5fa0776
5 files changed
+220
-4
No files matched your search
@@ -8,7 +8,8 @@ import 'package:fruitshorts/pages/discover/discover_logic.dart';
|
||||
|
||||
import '../support/fake_watch_history.dart';
|
||||
|
||||
Drama _drama(String id, {List<int> numbers = const [1, 2, 3]}) => Drama(
|
||||
Drama _drama(String id, {List<int> numbers = const [1, 2, 3], String language = ''}) => Drama(
|
||||
language: language,
|
||||
id: id,
|
||||
title: id,
|
||||
synopsis: 'synopsis',
|
||||
@@ -64,6 +65,36 @@ void main() {
|
||||
logic.dispose();
|
||||
});
|
||||
|
||||
test('should_filter_visible_dramas_when_language_is_selected', () {
|
||||
final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s'));
|
||||
final dramas = [
|
||||
_drama('zh', language: 'zh-CN'),
|
||||
_drama('id', language: 'id'),
|
||||
_drama('unknown'),
|
||||
];
|
||||
|
||||
expect(logic.visibleDramas(dramas), hasLength(3));
|
||||
|
||||
logic.selectLanguage('id');
|
||||
expect(logic.visibleDramas(dramas).map((item) => item.id), ['id']);
|
||||
|
||||
logic.selectLanguage(null);
|
||||
expect(logic.visibleDramas(dramas), hasLength(3));
|
||||
logic.dispose();
|
||||
});
|
||||
|
||||
test('should_list_distinct_languages_when_feed_has_cards', () {
|
||||
final logic = DiscoverLogic(history: FakeWatchHistory(), drama: _drama('s'));
|
||||
final dramas = [
|
||||
_drama('zh', language: 'zh-CN'),
|
||||
_drama('id', language: 'id'),
|
||||
_drama('id2', language: 'id'),
|
||||
_drama('unknown'),
|
||||
];
|
||||
|
||||
expect(logic.languagesOf(dramas), ['zh-CN', 'id']);
|
||||
logic.dispose();
|
||||
});
|
||||
test('should_have_no_resume_position_when_server_has_no_record', () async {
|
||||
final history = FakeWatchHistory();
|
||||
final logic = DiscoverLogic(
|
||||
|
||||
Reference in new issue
Block a user