-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8277f75
commit a4e650c
Showing
4 changed files
with
148 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_chat_types/flutter_chat_types.dart' as types; | ||
import 'package:flutter_chat_ui/flutter_chat_ui.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('contains file message', (WidgetTester tester) async { | ||
// Build the Chat widget. | ||
await tester.pumpWidget( | ||
MaterialApp( | ||
home: Material( | ||
child: Chat( | ||
messages: const [ | ||
types.FileMessage( | ||
author: types.User(id: '06c33e8b-e835-4736-80f4-63f44b66666c'), | ||
id: 'id', | ||
name: 'file', | ||
size: 100, | ||
uri: 'file', | ||
) | ||
], | ||
onSendPressed: (types.PartialText message) => {}, | ||
user: const types.User(id: '06c33e8b-e835-4736-80f4-63f44b66666c'), | ||
), | ||
), | ||
), | ||
); | ||
|
||
// Trigger a frame. | ||
await tester.pump(); | ||
|
||
// Expect to find one FileMessage | ||
expect(find.byType(FileMessage), findsOneWidget); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
import 'file_message.test.dart' as file_message_test; | ||
import 'image_message.test.dart' as image_message_test; | ||
import 'input.test.dart' as input_test; | ||
import 'text_message.test.dart' as text_message_test; | ||
import 'util.test.dart' as util_test; | ||
|
||
void main() { | ||
file_message_test.main(); | ||
image_message_test.main(); | ||
input_test.main(); | ||
text_message_test.main(); | ||
util_test.main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_chat_types/flutter_chat_types.dart' as types; | ||
import 'package:flutter_chat_ui/flutter_chat_ui.dart'; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('contains image message', (WidgetTester tester) async { | ||
// Build the Chat widget. | ||
await tester.pumpWidget( | ||
MaterialApp( | ||
home: Material( | ||
child: Chat( | ||
messages: const [ | ||
types.ImageMessage( | ||
author: types.User(id: '06c33e8b-e835-4736-80f4-63f44b66666c'), | ||
height: 1080, | ||
id: 'id', | ||
name: 'image', | ||
size: 100, | ||
uri: 'image', | ||
width: 1920, | ||
) | ||
], | ||
onSendPressed: (types.PartialText message) => {}, | ||
user: const types.User(id: '06c33e8b-e835-4736-80f4-63f44b66666c'), | ||
), | ||
), | ||
), | ||
); | ||
|
||
// Trigger a frame. | ||
await tester.pump(); | ||
|
||
// Expect to find one ImageMessage | ||
expect(find.byType(ImageMessage), findsOneWidget); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_chat_types/flutter_chat_types.dart' as types; | ||
import 'package:flutter_chat_ui/flutter_chat_ui.dart'; | ||
import 'package:flutter_link_previewer/flutter_link_previewer.dart' | ||
show LinkPreview; | ||
import 'package:flutter_test/flutter_test.dart'; | ||
|
||
void main() { | ||
testWidgets('contains text message', (WidgetTester tester) async { | ||
// Build the Chat widget. | ||
await tester.pumpWidget( | ||
MaterialApp( | ||
home: Material( | ||
child: Chat( | ||
messages: const [ | ||
types.TextMessage( | ||
author: types.User(id: '06c33e8b-e835-4736-80f4-63f44b66666c'), | ||
id: 'id', | ||
text: 'text', | ||
) | ||
], | ||
onSendPressed: (types.PartialText message) => {}, | ||
user: const types.User(id: '06c33e8b-e835-4736-80f4-63f44b66666c'), | ||
), | ||
), | ||
), | ||
); | ||
|
||
// Trigger a frame. | ||
await tester.pump(); | ||
|
||
// Expect to fine one TextMessage | ||
expect(find.byType(TextMessage), findsOneWidget); | ||
}); | ||
|
||
testWidgets('contains link preview', (WidgetTester tester) async { | ||
// Build the Chat widget. | ||
await tester.pumpWidget( | ||
MaterialApp( | ||
home: Material( | ||
child: Chat( | ||
messages: const [ | ||
types.TextMessage( | ||
author: types.User(id: '06c33e8b-e835-4736-80f4-63f44b66666c'), | ||
id: 'id', | ||
previewData: types.PreviewData( | ||
description: 'Flutter', | ||
link: 'https://flutter.dev/', | ||
title: 'Flutter', | ||
), | ||
text: 'https://flutter.dev/', | ||
) | ||
], | ||
onPreviewDataFetched: | ||
(types.TextMessage message, types.PreviewData previewData) => | ||
{}, | ||
onSendPressed: (types.PartialText message) => {}, | ||
user: const types.User(id: '06c33e8b-e835-4736-80f4-63f44b66666c'), | ||
), | ||
), | ||
), | ||
); | ||
|
||
// Trigger a frame. | ||
await tester.pump(); | ||
|
||
// Expect to find one LinkPreview | ||
expect(find.byType(LinkPreview), findsOneWidget); | ||
}); | ||
} |