forked from openfoodfacts/openfoodfacts-dart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: issue with JSON conversion of packagings data (openfoodfacts#762)
* fix: issue with JSON conversion of packagings data Fixes openfoodfacts#752 * refactor: address PR openfoodfacts#762 feedback * fix: address more PR openfoodfacts#762 feedback
- Loading branch information
Showing
5 changed files
with
49 additions
and
9 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
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,18 @@ | ||
import 'package:openfoodfacts/openfoodfacts.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
void main() { | ||
test('ProductPackaging bug', () { | ||
final testProduct = Product(); | ||
const productName = 'Orange'; | ||
testProduct.productName = productName; | ||
const expectedQuantity = '75cl'; | ||
testProduct.packagings = [ | ||
ProductPackaging()..quantityPerUnit = expectedQuantity | ||
]; | ||
final productJson = testProduct.toJson(); | ||
final productRestored = Product.fromJson(productJson); | ||
expect(productRestored.productName, productName); | ||
expect(productRestored.packagings!.first.quantityPerUnit, expectedQuantity); | ||
}); | ||
} |