Create buttons_test.dart

This commit is contained in:
Ashita Prasad
2023-04-18 21:27:11 +05:30
parent 44f97d3612
commit 47d09f039f

View File

@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:apidash/widgets/buttons.dart';
void main() {
String copyText = 'This is a sample response generated by ';
testWidgets('Testing for copy icon', (tester) async {
await tester.pumpWidget(
MaterialApp(
title: 'Copy Button',
home: Scaffold(
body: CopyButton(toCopy: copyText),
),
),
);
expect(find.byIcon(Icons.content_copy), findsOneWidget);
expect(find.text('Copy'), findsOneWidget);
final textButton1 = find.byType(TextButton);
expect(textButton1, findsOneWidget);
await tester.tap(textButton1);
var data = await Clipboard.getData('text/plain');
expect(data?.text, copyText);
});
}