diff --git a/test/widgets/buttons_test.dart b/test/widgets/buttons_test.dart new file mode 100644 index 00000000..cfebe1d3 --- /dev/null +++ b/test/widgets/buttons_test.dart @@ -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); + }); +}