Skip to content

Commit

Permalink
added option traverse do notation test
Browse files Browse the repository at this point in the history
  • Loading branch information
SandroMaglione committed Oct 12, 2023
1 parent c72edeb commit d2d21ad
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/fpdart/test/src/option_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,27 @@ void main() {
});

group('Do Notation', () {
test('should traverse over a list', () async {
const testOption = const Option<List<String?>>.of(
['/', '/test', null],
);

Option<List<Uri>> doNotation = Option.Do(
($) {
List<String?> optionList = $(testOption);
return $(optionList.traverseOption(
(stringValue) => optionOf(stringValue).flatMap(
(uri) => optionOf(
Uri.tryParse(uri),
),
),
));
},
);

expect(doNotation, equals(const Option<Uri>.none()));
});

test('should return the correct value', () {
final doOption = Option.Do((_) => _(Option.of(10)));
doOption.matchTestSome((t) {
Expand Down

0 comments on commit d2d21ad

Please sign in to comment.