diff --git a/test/core/augmented_form_test.dart b/test/core/augmented_form_test.dart index dbb2c7e2..c807bb0e 100644 --- a/test/core/augmented_form_test.dart +++ b/test/core/augmented_form_test.dart @@ -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", @@ -29,7 +35,15 @@ void main() { } ], }, + "test2": { + "forms": [ + { + "href": "/test", + }, + ], + }, }, + "base": href2, "security": ["nosec_sc"], "securityDefinitions": { "nosec_sc": { @@ -50,11 +64,28 @@ void main() { expect(augmentedForm.href, Uri.parse(href)); expect(augmentedForm.security, ["nosec_sc"]); expect(augmentedForm.securityDefinitions.first, isA()); - 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")); }); }); }