mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Create buttons_test.dart
This commit is contained in:
27
test/widgets/buttons_test.dart
Normal file
27
test/widgets/buttons_test.dart
Normal 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);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user