|
| 1 | +import 'package:alchemist/alchemist.dart'; |
1 | 2 | import 'package:flutter/material.dart';
|
2 | 3 | import 'package:flutter_test/flutter_test.dart';
|
3 | 4 | import 'package:mocktail/mocktail.dart';
|
@@ -476,4 +477,73 @@ void main() {
|
476 | 477 | expect(titleTapped, true);
|
477 | 478 | },
|
478 | 479 | );
|
| 480 | + |
| 481 | + goldenTest( |
| 482 | + 'golden test for StreamChannelHeader with bottom widget', |
| 483 | + fileName: 'channel_header_bottom_widget', |
| 484 | + constraints: const BoxConstraints.tightFor(width: 300, height: 60), |
| 485 | + builder: () { |
| 486 | + final client = MockClient(); |
| 487 | + final clientState = MockClientState(); |
| 488 | + final channel = MockChannel(); |
| 489 | + final channelState = MockChannelState(); |
| 490 | + final user = OwnUser(id: 'user-id'); |
| 491 | + final lastMessageAt = DateTime.parse('2020-06-22 12:00:00'); |
| 492 | + |
| 493 | + when(() => client.state).thenReturn(clientState); |
| 494 | + when(() => clientState.currentUser).thenReturn(user); |
| 495 | + when(() => clientState.currentUserStream) |
| 496 | + .thenAnswer((_) => Stream.value(user)); |
| 497 | + when(() => channel.lastMessageAt).thenReturn(lastMessageAt); |
| 498 | + when(() => channel.state).thenReturn(channelState); |
| 499 | + when(() => channel.client).thenReturn(client); |
| 500 | + when(() => channel.isMuted).thenReturn(false); |
| 501 | + when(() => channel.isMutedStream).thenAnswer((i) => Stream.value(false)); |
| 502 | + when(() => channel.nameStream).thenAnswer((_) => Stream.value('test')); |
| 503 | + when(() => channel.name).thenReturn('test'); |
| 504 | + when(() => channel.imageStream) |
| 505 | + .thenAnswer((i) => Stream.value('https://bit.ly/321RmWb')); |
| 506 | + when(() => channel.image).thenReturn('https://bit.ly/321RmWb'); |
| 507 | + when(() => channelState.unreadCount).thenReturn(1); |
| 508 | + when(() => client.wsConnectionStatusStream) |
| 509 | + .thenAnswer((_) => Stream.value(ConnectionStatus.connected)); |
| 510 | + when(() => channelState.unreadCountStream) |
| 511 | + .thenAnswer((i) => Stream.value(1)); |
| 512 | + when(() => clientState.totalUnreadCount).thenAnswer((i) => 1); |
| 513 | + when(() => clientState.totalUnreadCountStream) |
| 514 | + .thenAnswer((i) => Stream.value(1)); |
| 515 | + when(() => channelState.membersStream).thenAnswer( |
| 516 | + (i) => Stream.value([ |
| 517 | + Member( |
| 518 | + userId: 'user-id', |
| 519 | + user: User(id: 'user-id'), |
| 520 | + ) |
| 521 | + ]), |
| 522 | + ); |
| 523 | + when(() => channelState.members).thenReturn([ |
| 524 | + Member( |
| 525 | + userId: 'user-id', |
| 526 | + user: User(id: 'user-id'), |
| 527 | + ), |
| 528 | + ]); |
| 529 | + |
| 530 | + return MaterialAppWrapper( |
| 531 | + home: StreamChat( |
| 532 | + client: client, |
| 533 | + connectivityStream: Stream.value([ConnectivityResult.wifi]), |
| 534 | + child: StreamChannel( |
| 535 | + channel: channel, |
| 536 | + child: const Scaffold( |
| 537 | + body: StreamChannelHeader( |
| 538 | + bottom: PreferredSize( |
| 539 | + preferredSize: Size.fromHeight(1), |
| 540 | + child: Divider(height: 1, color: Colors.red), |
| 541 | + ), |
| 542 | + ), |
| 543 | + ), |
| 544 | + ), |
| 545 | + ), |
| 546 | + ); |
| 547 | + }, |
| 548 | + ); |
479 | 549 | }
|
0 commit comments