mirrored_repositories/apidash/test
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:apidash/widgets/menus.dart';
import 'package:apidash/consts.dart';
import '../test_consts.dart';

void main() {
  testWidgets('Testing RequestCardMenu', (tester) async {
    dynamic changedValue;
    await tester.pumpWidget(
      MaterialApp(
        title: 'CardMenu testing',
        theme: kThemeDataLight,
        home: Scaffold(
          body: Center(
            child: Column(
              children: [
                RequestCardMenu(
                  onSelected: (value) {
                    changedValue = value;
                  },
                ),
              ],
            ),
          ),
        ),
      ),
    );

    expect(find.byType(PopupMenuButton<RequestItemMenuOption>), findsOneWidget);

    await tester.tap(find.byType(PopupMenuButton<RequestItemMenuOption>));
    await tester.pump();
    await tester.pump(const Duration(seconds: 1));

    await tester.tap(find.text('Delete').last);
    await tester.pump();
    await tester.pump(const Duration(seconds: 1));

    expect(changedValue, RequestItemMenuOption.delete);

    await tester.tap(find.byType(PopupMenuButton<RequestItemMenuOption>));
    await tester.pump();
    await tester.pump(const Duration(seconds: 1));

    await tester.tap(find.text('Duplicate').last);
    await tester.pump();
    await tester.pump(const Duration(seconds: 1));

    expect(changedValue, RequestItemMenuOption.duplicate);
  });
}
