Skip to content

Commit

Permalink
test(InteractionOutput): add additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 27, 2024
1 parent 57a303b commit a4af92b
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions test/core/interaction_output_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<NotReadableException>(),
),
);
});
});

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<NotReadableException>(),
),
);
});

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);
});
}

0 comments on commit a4af92b

Please sign in to comment.