From 8e73131df3149ce555030e1f9f99125df4cae288 Mon Sep 17 00:00:00 2001 From: Jan Romann Date: Sun, 2 Jun 2024 16:15:15 +0200 Subject: [PATCH] fixup! feat!: improve deserialization logic --- test/core/definitions_test.dart | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/test/core/definitions_test.dart b/test/core/definitions_test.dart index f1366ca2..7e6f44b5 100644 --- a/test/core/definitions_test.dart +++ b/test/core/definitions_test.dart @@ -615,4 +615,53 @@ void main() { throwsA(isA()), ); }); + + test("Should throw FormatExceptions for incorrect DataSchema types in TDs", + () { + final invalidThingDescription = { + "@context": ["https://www.w3.org/2022/wot/td/v1.1"], + "title": "Thingweb WoT Thing", + "security": ["nosec_sc"], + "securityDefinitions": { + "nosec_sc": { + "scheme": "nosec", + }, + }, + "schemaDefinitions": { + "invalidSchema": 42, + }, + }; + + expect( + () => ThingDescription.fromJson(invalidThingDescription), + throwsA(isA()), + ); + }); + + test( + "Should throw FormatExceptions for empty affordance forms in TDs", + () { + final invalidThingDescription = { + "@context": ["https://www.w3.org/2022/wot/td/v1.1"], + "title": "Thingweb WoT Thing", + "security": ["nosec_sc"], + "securityDefinitions": { + "nosec_sc": { + "scheme": "nosec", + }, + }, + "actions": { + "testAction": { + "forms": [], + }, + }, + }; + + expect( + () => ThingDescription.fromJson(invalidThingDescription), + throwsA(isA()), + ); + }, + skip: true, + ); }