Skip to content

Commit

Permalink
fixup! feat!: improve TD serialization behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 3, 2024
1 parent 2988b72 commit 8612e25
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion test/core/augmented_form_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@ import "package:test/test.dart";
void main() {
group("AugmentedForm should", () {
test("be able to be instantiated", () {
const id = "urn:foobar";
const href = "http://example.org";
const href2 = "coap://example.org";
final thingDescription = ThingDescription.fromJson(
const {
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"title": "Test TD",
"id": id,
"properties": {
"test": {
"forms": [
{
"href": href,
"contentCoding": "gzip",
"scopes": ["hi"],
"subprotocol": "Hyper Text Coffee Pot Control Protocol",
"additionalResponses": [
{
"contentType": "application/json",
Expand All @@ -29,7 +35,15 @@ void main() {
}
],
},
"test2": {
"forms": [
{
"href": "/test",
},
],
},
},
"base": href2,
"security": ["nosec_sc"],
"securityDefinitions": {
"nosec_sc": {
Expand All @@ -50,11 +64,28 @@ void main() {
expect(augmentedForm.href, Uri.parse(href));
expect(augmentedForm.security, ["nosec_sc"]);
expect(augmentedForm.securityDefinitions.first, isA<NoSecurityScheme>());
expect(augmentedForm.tdIdentifier, "Test TD");
expect(augmentedForm.tdIdentifier, id);
expect(
augmentedForm.additionalResponses?.first.contentType,
"application/json",
);
expect(augmentedForm.contentCoding, "gzip");
expect(augmentedForm.contentType, "application/json");
expect(augmentedForm.scopes, ["hi"]);
expect(
augmentedForm.subprotocol,
"Hyper Text Coffee Pot Control Protocol",
);

final affordance2 = thingDescription.properties?["test2"];

final augmentedForm2 = AugmentedForm(
affordance2!.forms[0],
affordance2,
thingDescription,
const {},
);
expect(augmentedForm2.href, Uri.parse("$href2/test"));
});
});
}

0 comments on commit 8612e25

Please sign in to comment.