Skip to content

Commit

Permalink
fixup! feat!: improve deserialization logic
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jun 2, 2024
1 parent 062410e commit 8e73131
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions test/core/definitions_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,53 @@ void main() {
throwsA(isA<FormatException>()),
);
});

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<FormatException>()),
);
});

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<FormatException>()),
);
},
skip: true,
);
}

0 comments on commit 8e73131

Please sign in to comment.