import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:recording_tool/features/recording/widgets/widget_record_header.dart';
import 'package:recording_tool/gen/assets.gen.dart';

void main() {
  Future<void> pumpHeader(
    WidgetTester tester, {
    required bool hasValidClipboardInfo,
    String? eventTitle,
  }) async {
    await tester.pumpWidget(
      ScreenUtilInit(
        designSize: const Size(375, 812),
        builder: (context, _) {
          return MaterialApp(
            home: Scaffold(
              body: RecordHeaderWidget(
                hasValidClipboardInfo: hasValidClipboardInfo,
                eventTitle: eventTitle,
                isRecording: false,
                onPasteEventInfo: () async {},
                onClearEventInfo: () {},
              ),
            ),
          );
        },
      ),
    );
  }

  testWidgets('paste player info button uses copy image asset', (tester) async {
    await pumpHeader(tester, hasValidClipboardInfo: false);

    expect(find.text('粘贴选手信息'), findsOneWidget);
    expect(find.image(AssetImage(Assets.images.imageCopy.path)), findsOne);
  });

  testWidgets('clear player info button uses delete image asset', (
    tester,
  ) async {
    await pumpHeader(
      tester,
      hasValidClipboardInfo: true,
      eventTitle: '王东方 丨李想 空中格斗赛',
    );

    expect(find.text('王东方 丨李想 空中格斗赛'), findsOneWidget);
    expect(find.image(AssetImage(Assets.images.imageDelete.path)), findsOne);
  });
}
