Skip to content

Commit 5c495b4

Browse files
committed
test: add tests for InteractionOutput class
1 parent 7b2a9d8 commit 5c495b4

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2023 Contributors to the Eclipse Foundation. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
//
5+
// SPDX-License-Identifier: BSD-3-Clause
6+
7+
import 'dart:convert';
8+
9+
import 'package:dart_wot/src/core/content.dart';
10+
import 'package:dart_wot/src/core/content_serdes.dart';
11+
import 'package:dart_wot/src/core/interaction_output.dart';
12+
import 'package:test/test.dart';
13+
14+
void main() {
15+
group('InteractionOutput should', () {
16+
test('output the correct value', () async {
17+
const inputValue = 'foo';
18+
final input = utf8.encode(inputValue);
19+
20+
final contentSerdes = ContentSerdes();
21+
final content = Content(
22+
'text/plain',
23+
Stream.fromIterable([
24+
input,
25+
]),
26+
);
27+
28+
final interactionOutput = InteractionOutput(content, contentSerdes);
29+
30+
final value1 = await interactionOutput.value();
31+
expect(value1, inputValue);
32+
33+
// Should return the same value
34+
final value2 = await interactionOutput.value();
35+
expect(value2, inputValue);
36+
});
37+
38+
test('output the same value when calling value() twice', () async {
39+
const inputValue = 'bar';
40+
final input = utf8.encode(inputValue);
41+
42+
final contentSerdes = ContentSerdes();
43+
final content = Content(
44+
'text/plain',
45+
Stream.fromIterable([
46+
input,
47+
]),
48+
);
49+
50+
final interactionOutput = InteractionOutput(content, contentSerdes);
51+
52+
final value1 = await interactionOutput.value();
53+
expect(value1, inputValue);
54+
55+
final value2 = await interactionOutput.value();
56+
expect(value1, value2);
57+
});
58+
});
59+
}

0 commit comments

Comments
 (0)