import 'package:flutter_test/flutter_test.dart';
import 'package:smplayer/core/contracts/library.dart';
import 'package:smplayer/features/detail/emby_detail_helpers.dart';

void main() {
  group('detailNavTitle', () {
    test('uses series name for selected episode', () {
      const episode = EmbyRawItem(
        Id: 'ep1',
        Name: '第 1 集',
        Type: 'Episode',
        SeriesName: '我的剧',
      );

      expect(detailNavTitle(episode, null), '我的剧');
    });

    test('uses loaded series item before episode name', () {
      const episode = EmbyRawItem(
        Id: 'ep1',
        Name: '第 1 集',
        Type: 'Episode',
      );
      const series = EmbyRawItem(Id: 'series1', Name: '正片剧名', Type: 'Series');

      expect(detailNavTitle(episode, series), '正片剧名');
    });

    test('keeps movie title', () {
      const movie = EmbyRawItem(Id: 'movie1', Name: '电影名', Type: 'Movie');

      expect(detailNavTitle(movie, null), '电影名');
    });
  });
}
