-
-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix!: fix for the uk/gb country code case (#795)
* fix!: fix for the uk/gb country code case Impacted files: * `country_helper.dart`: `fromOffTag` now includes a fix for the uk/gb case; breaking change - removed class `CountryHelper` * `open_food_api_client.dart`: breaking change - `getOrderedNutrients` now uses parameter `OpenFoodFactsCountry country` * `ordered_nutrient_test.dart`: minor refactoring * fix!: fix for the uk/gb country code case New file: * `api_off_tag_test.dart`: Tests about OffTagged enums. Impacted file: * `country_helper.dart`: case-insensitive search.
- Loading branch information
1 parent
0bd8f90
commit fc2e907
Showing
4 changed files
with
45 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
/// Tests about [OffTagged] `enum`s. | ||
void main() { | ||
test('$OpenFoodAPIClient country', () async { | ||
const Map<String?, OpenFoodFactsCountry?> expectedCountries = | ||
<String?, OpenFoodFactsCountry?>{ | ||
'fr': OpenFoodFactsCountry.FRANCE, | ||
'FR': OpenFoodFactsCountry.FRANCE, | ||
'fR': OpenFoodFactsCountry.FRANCE, | ||
'Fr': OpenFoodFactsCountry.FRANCE, | ||
'uk': OpenFoodFactsCountry.UNITED_KINGDOM, | ||
'UK': OpenFoodFactsCountry.UNITED_KINGDOM, | ||
'gb': OpenFoodFactsCountry.UNITED_KINGDOM, | ||
'GB': OpenFoodFactsCountry.UNITED_KINGDOM, | ||
null: null, | ||
'this is not a country code': null, | ||
}; | ||
for (final MapEntry<String?, OpenFoodFactsCountry?> entry | ||
in expectedCountries.entries) { | ||
expect(OpenFoodFactsCountry.fromOffTag(entry.key), entry.value); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters