import 'dart:convert';

import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:smplayer/core/infra/storage/search_history_store.dart';

void main() {
  test('旧 JSON 搜索历史读取后迁移为字符串列表', () async {
    SharedPreferences.setMockInitialValues({
      'smplayer.search_history': jsonEncode(['电影', '剧集']),
    });

    expect(await SearchHistoryStore().list(), ['电影', '剧集']);

    final prefs = await SharedPreferences.getInstance();
    expect(prefs.getStringList('smplayer.search_history'), ['电影', '剧集']);
  });
}
