Skip to content

Commit

Permalink
test: improve ConsumedThing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 3, 2024
1 parent 0987df7 commit 18a2147
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions test/core/consumed_thing_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ import "package:dart_wot/src/definitions/validation/validation_exception.dart";
import "package:test/test.dart";

void main() {
group("Consumed Thing Tests", () {
setUp(() {
// Additional setup goes here.
});

test("Parse Interaction Affordances", () async {
group("ConsumedThing should", () {
test("parse Interaction Affordances", () async {
const thingDescriptionJson = {
"@context": [
"https://www.w3.org/2022/wot/td/v1.1",
Expand Down Expand Up @@ -202,7 +198,7 @@ void main() {
});

test(
"Use of URI Template Variables",
"use URI Template Variables",
() async {
const thingDescriptionJson = {
"@context": ["http://www.w3.org/ns/td"],
Expand Down Expand Up @@ -262,4 +258,30 @@ void main() {
},
skip: true, // TODO: Replace with test with local server
);

test("throw ArgumentErrors for missing Affordances", () async {
const thingDescriptionJson = {
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"title": "Test Thing",
"securityDefinitions": {
"nosec_sc": {"scheme": "nosec"},
},
"security": "nosec_sc",
"uriVariables": {
"value": {"type": "string"},
},
};

final parsedTd = ThingDescription.fromJson(thingDescriptionJson);

final servient = Servient();
final wot = await servient.start();

final consumedThing = await wot.consume(parsedTd);

expect(
() async => await consumedThing.readProperty("test"),
throwsArgumentError,
);
});
}

0 comments on commit 18a2147

Please sign in to comment.