Skip to content

Commit

Permalink
feat: 951 - new method User.getUserWikiPage (#955)
Browse files Browse the repository at this point in the history
* feat: 951 - new method User.getUserWikiPage

Impacted files:
* `user.dart`: new method `getUserWikiPage`
* `user_management_test_prod.dart`: test of new method `User.getUserWikiPage`

* Unrelated test minor fix.
  • Loading branch information
monsieurtanuki authored Jul 26, 2024
1 parent fed91fe commit f57e51c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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

0 comments on commit f57e51c

Please sign in to comment.