Skip to content

Commit

Permalink
modified
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhin29 committed Nov 28, 2023
1 parent 456dffa commit 960d334
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/widgets/pinned_post.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:talawa/locator.dart';
import 'package:talawa/models/post/post_model.dart';
import 'package:talawa/services/size_config.dart';
import 'package:talawa/views/after_auth_screens/feed/pinned_post_screen.dart';

/// a_line_ending_with_end_punctuation.
///
Expand Down Expand Up @@ -101,10 +102,10 @@ class PinnedPost extends StatelessWidget {
child: GestureDetector(
onTap: () {
// final Map<String, dynamic> arg = {"index": "$index","post": pinnedPosts};
navigationService.pushScreen(
'/pinnedpostscreen',
arguments: pinnedPosts[index],
);
Navigator.of(context).push(MaterialPageRoute(
builder: (context) =>
PinnedPostScreen(post: pinnedPosts[index]),
));
},
child: SizedBox(
width: SizeConfig.screenWidth! / 4.1,
Expand Down
19 changes: 19 additions & 0 deletions test/widget_tests/widgets/pinned_post_test.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:talawa/demo_server_data/pinned_post_demo_data.dart';
import 'package:talawa/locator.dart';
import 'package:talawa/models/post/post_model.dart';
import 'package:talawa/services/navigation_service.dart';
import 'package:talawa/services/size_config.dart';
import 'package:talawa/views/after_auth_screens/feed/pinned_post_screen.dart';
import 'package:talawa/widgets/pinned_post.dart';

import '../../helpers/test_helpers.dart';
Expand All @@ -28,11 +31,14 @@ List<Post> get pinnedPosts {
/// **returns**:
/// None
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
setupLocator();
locator<SizeConfig>().test();
NavigationService navigationService;
setUp(() {
registerServices();
locator<SizeConfig>().test();
navigationService = NavigationService();
});
tearDown(() {
unregisterServices();
Expand Down Expand Up @@ -69,4 +75,17 @@ void main() {
await widgetTester.pumpAndSettle();
expect(find.text('Church Meeting'), findsOneWidget);
});

testWidgets('Tapping on a post triggers navigation', (widgetTester) async {
await widgetTester.pumpWidget(
MaterialApp(
home: PinnedPost(pinnedPost: pinnedPosts),
),
);
await widgetTester.pump();
await widgetTester.tap(find.text('1hr'));
await widgetTester.pumpAndSettle();
expect(find.byType(PinnedPost), findsNothing);
expect(find.byType(PinnedPostScreen), findsOneWidget);
});
}

0 comments on commit 960d334

Please sign in to comment.