chore: rename method signature

pull/225/head
Jonathan Daniels 3 years ago committed by jonathandaniels-vgv
parent dfac24398a
commit 84c3dda060

@ -11,17 +11,17 @@ class ShareRepository {
final String _appUrl; final String _appUrl;
/// Returns a url to share the [shareText] on the given [platform]. /// Returns a url to share the [value] on the given [platform].
/// ///
/// The returned url can be opened using the [url_launcher](https://pub.dev/packages/url_launcher) package. /// The returned url can be opened using the [url_launcher](https://pub.dev/packages/url_launcher) package.
/// ///
/// The [shareText] must have the score embedded. /// The [value] must have the score embedded.
String shareScore({ String shareText({
required String shareText, required String value,
required SharePlatform platform, required SharePlatform platform,
}) { }) {
final encodedUrl = Uri.encodeComponent(_appUrl); final encodedUrl = Uri.encodeComponent(_appUrl);
final encodedShareText = Uri.encodeComponent(shareText); final encodedShareText = Uri.encodeComponent(value);
switch (platform) { switch (platform) {
case SharePlatform.twitter: case SharePlatform.twitter:
return 'https://twitter.com/intent/tweet?url=$encodedUrl&text=$encodedShareText'; return 'https://twitter.com/intent/tweet?url=$encodedUrl&text=$encodedShareText';

@ -15,13 +15,13 @@ void main() {
expect(ShareRepository(appUrl: appUrl), isNotNull); expect(ShareRepository(appUrl: appUrl), isNotNull);
}); });
group('shareScore', () { group('shareText', () {
const shareText = 'hello world!'; const shareText = 'hello world!';
test('returns the correct share url for twitter', () async { test('returns the correct share url for twitter', () async {
const shareScoreUrl = const shareScoreUrl =
'https://twitter.com/intent/tweet?url=https%3A%2F%2Ffakeurl.com%2F&text=hello%20world!'; 'https://twitter.com/intent/tweet?url=https%3A%2F%2Ffakeurl.com%2F&text=hello%20world!';
final shareScoreResult = shareRepository.shareScore( final shareScoreResult = shareRepository.shareText(
shareText: shareText, value: shareText,
platform: SharePlatform.twitter, platform: SharePlatform.twitter,
); );
expect(shareScoreResult, equals(shareScoreUrl)); expect(shareScoreResult, equals(shareScoreUrl));
@ -30,8 +30,8 @@ void main() {
test('returns the correct share url for facebook', () async { test('returns the correct share url for facebook', () async {
const shareScoreUrl = const shareScoreUrl =
'https://www.facebook.com/sharer.php?u=https%3A%2F%2Ffakeurl.com%2F&quote=hello%20world!'; 'https://www.facebook.com/sharer.php?u=https%3A%2F%2Ffakeurl.com%2F&quote=hello%20world!';
final shareScoreResult = shareRepository.shareScore( final shareScoreResult = shareRepository.shareText(
shareText: shareText, value: shareText,
platform: SharePlatform.facebook, platform: SharePlatform.facebook,
); );
expect(shareScoreResult, equals(shareScoreUrl)); expect(shareScoreResult, equals(shareScoreUrl));

Loading…
Cancel
Save