Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Docstrings to test/social_service_test.dart #31

Merged
merged 2 commits into from
Dec 30, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: Updated test/social_service_test.dart
  • Loading branch information
sweep-ai[bot] authored Dec 30, 2023
commit 6224e07cd3e41c256be5694babab983c0e675b21
4 changes: 4 additions & 0 deletions test/social_service_test.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
/// Tests for the 'launchUrl' function in the 'SocialService' class.
import 'package:flutter_test/flutter_test.dart';
import 'package:mockito/mockito.dart';
import 'package:traffic_report_front_flutter/services/social_service.dart';
import 'package:url_launcher/url_launcher.dart';

class MockUrlLauncher extends Mock implements UrlLauncher {}

/// The 'main' function is the entry point for the tests and contains a group of tests for the 'launchUrl' function.
void main() {
group('launchUrl', () {
final mockUrlLauncher = MockUrlLauncher();
final socialService = SocialService();

/// Tests if the 'launchUrl' function can successfully launch a URL.
test('launches URL successfully', () async {
when(mockUrlLauncher.canLaunch(any)).thenAnswer((_) async => true);
when(mockUrlLauncher.launch(any)).thenAnswer((_) async => true);

expect(await socialService.launchUrl('http://valid.url'), completes);
});

/// Tests if the 'launchUrl' function throws an exception when the URL cannot be launched.
test('throws an exception when URL cannot be launched', () async {
when(mockUrlLauncher.canLaunch(any)).thenAnswer((_) async => false);