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 0604c4f commit d60bdc9
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/core/augmented_form_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright 2024 Contributors to the Eclipse Foundation. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
// SPDX-License-Identifier: BSD-3-Clause

import "package:dart_wot/dart_wot.dart";
import "package:dart_wot/src/definitions/security/no_security_scheme.dart";
import "package:test/test.dart";

void main() {
group("AugmentedForm should", () {
test("be able to be instantiated", () {
const href = "http://example.org";
final thingDescription = ThingDescription.fromJson(
const {
"@context": "https://www.w3.org/2022/wot/td/v1.1",
"title": "Test TD",
"properties": {
"test": {
"forms": [
{
"href": href,
}
],
},
},
"security": ["nosec_sc"],
"securityDefinitions": {
"nosec_sc": {
"scheme": "nosec",
},
},
},
);
final affordance = thingDescription.properties?["test"];

final augmentedForm = AugmentedForm(
affordance!.forms.first,
affordance,
thingDescription,
const {},
);

expect(augmentedForm.href, Uri.parse(href));
expect(augmentedForm.security, ["nosec_sc"]);
expect(augmentedForm.securityDefinitions.first, isA<NoSecurityScheme>());
expect(augmentedForm.tdIdentifier, "Test TD");
});
});
}

0 comments on commit d60bdc9

Please sign in to comment.