From a4af92b635b4b29b0f650c8242f14e9978bf6642 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Sat, 27 Jan 2024 22:19:13 +0100 Subject: [PATCH] test(InteractionOutput): add additional tests --- test/core/interaction_output_test.dart | 71 ++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/test/core/interaction_output_test.dart b/test/core/interaction_output_test.dart index ee3780ed..0f4d41f9 100644 --- a/test/core/interaction_output_test.dart +++ b/test/core/interaction_output_test.dart @@ -64,5 +64,76 @@ void main() { final value2 = await interactionOutput.value(); expect(value1, value2); }); + + test( + "throw a NotReadableException when calling the arrayBuffer() method " + "twice", () async { + final contentSerdes = ContentSerdes(); + final content = Content( + "text/plain", + const Stream.empty(), + ); + + final interactionOutput = InteractionOutput( + content, + contentSerdes, + Form(Uri.parse("http://example.org")), + const DataSchema(), + ); + + await interactionOutput.arrayBuffer(); + + final result = interactionOutput.arrayBuffer(); + await expectLater( + result, + throwsA( + isA(), + ), + ); + }); + }); + + test( + "throw a NotReadableException in the value() method when no schema is " + "defined", () async { + final contentSerdes = ContentSerdes(); + final content = Content( + "text/plain", + const Stream.empty(), + ); + + final interactionOutput = InteractionOutput( + content, + contentSerdes, + Form(Uri.parse("http://example.org")), + null, + ); + + final result = interactionOutput.value(); + await expectLater( + result, + throwsA( + isA(), + ), + ); + }); + + test("allow accessing the form field", () async { + final contentSerdes = ContentSerdes(); + final content = Content( + "text/plain", + const Stream.empty(), + ); + + final uri = Uri.parse("http://example.org"); + + final interactionOutput = InteractionOutput( + content, + contentSerdes, + Form(uri), + const DataSchema(), + ); + + expect(interactionOutput.form.href, uri); }); }