From 1fc93bdee1d16e8ba42aa0ddfb0bfc37d1f9737f Mon Sep 17 00:00:00 2001 From: ndelanou Date: Tue, 5 Dec 2023 15:58:27 +0100 Subject: [PATCH 1/2] fix(docs): typo in example extra_codec.dart --- packages/go_router/example/lib/extra_codec.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/go_router/example/lib/extra_codec.dart b/packages/go_router/example/lib/extra_codec.dart index 497312cb5303..f7ae2a4f576c 100644 --- a/packages/go_router/example/lib/extra_codec.dart +++ b/packages/go_router/example/lib/extra_codec.dart @@ -116,7 +116,7 @@ class _MyExtraDecoder extends Converter { if (inputAsList[0] == 'ComplexData2') { return ComplexData2(inputAsList[1]! as String); } - throw FormatException('Unable tp parse input: $input'); + throw FormatException('Unable to parse input: $input'); } } From 113eaff7b4eb57be883949df8c8bc27733edc46d Mon Sep 17 00:00:00 2001 From: ndelanou Date: Wed, 6 Dec 2023 11:01:06 +0100 Subject: [PATCH 2/2] add invalid extra_codec test --- .../go_router/example/test/extra_codec_test.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/go_router/example/test/extra_codec_test.dart b/packages/go_router/example/test/extra_codec_test.dart index 7358cfc614ed..e42b19ddb3b3 100644 --- a/packages/go_router/example/test/extra_codec_test.dart +++ b/packages/go_router/example/test/extra_codec_test.dart @@ -20,4 +20,20 @@ void main() { expect(find.text('The extra for this page is: ComplexData2(data: data)'), findsOneWidget); }); + + test('invalid extra throws', () { + const example.MyExtraCodec extraCodec = example.MyExtraCodec(); + const List invalidValue = ['invalid']; + + expect( + () => extraCodec.decode(invalidValue), + throwsA( + predicate( + (Object? exception) => + exception is FormatException && + exception.message == 'Unable to parse input: $invalidValue', + ), + ), + ); + }); }