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

feat: 951 - new method User.getUserWikiPage #955

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 7 additions & 0 deletions lib/src/model/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,11 @@ class User extends JsonObject {

@override
Map<String, dynamic> toJson() => _$UserToJson(this);

static String getUserWikiPage(final String userId) => Uri(
scheme: 'https',
host: 'wiki.openfoodfacts.org',
path: 'User:'
'${userId.substring(0, 1).toUpperCase()}${userId.substring(1)}',
).toString();
}
4 changes: 2 additions & 2 deletions test/api_get_save_product_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void main() {

final String barcode = getBookBarcode(0);
const OpenFoodFactsLanguage language = OpenFoodFactsLanguage.GERMAN;
const String genericName = 'Softdrink';
const String genericName = 'Softdrink beverage';
const List<String> ingredientsText = <String>[
'Wasser',
'Kohlensäure',
Expand Down Expand Up @@ -711,7 +711,7 @@ void main() {
}

const String barcode = '111111555555';
const String genericName = 'Softdrink';
const String genericName = 'Softdrink beverage';
const String labels = 'MyTestLabel';
const String quantity = '5.5 Liter';

Expand Down
9 changes: 9 additions & 0 deletions test/user_management_test_prod.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,15 @@ void main() {
expect(status.status, koStatus);
});
});

group('wiki page', () {
test('user wiki page', () async {
expect(
User.getUserWikiPage('teolemon'),
'https://wiki.openfoodfacts.org/User:Teolemon',
);
});
});
}

String _generateRandomString(int length) {
Expand Down