Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for glTF extension validation #70

Merged
merged 6 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions specs/metadata/MetadataEntityModelSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ describe("metadata/MetadataEntityModel", function () {
const testMetadataClass: MetadataClass = {
properties: {},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: 1234,
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
entity.getPropertyValue("testProperty");
Expand All @@ -34,11 +36,13 @@ describe("metadata/MetadataEntityModel", function () {
},
},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: undefined,
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
Expand All @@ -56,17 +60,69 @@ describe("metadata/MetadataEntityModel", function () {
},
},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: 2345,
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
expect(value).toBe(1234);
});

it("obtains a default value for an enum noData value", function () {
const testMetadataClass: MetadataClass = {
properties: {
testProperty: {
type: "ENUM",
enumType: "testEnum",
noData: "TEST_NO_DATA_ENUM_VALUE",
default: "TEST_DEFAULT_ENUM_VALUE",
},
},
};
const testMetadataEnums = {
testEnum: {
valueType: "UINT8",
values: [
{
name: "TEST_NO_DATA_ENUM_VALUE",
value: 255,
},
{
name: "TEST_ENUM_VALUE_A",
value: 1,
},
{
name: "TEST_ENUM_VALUE_B",
value: 2,
},
{
name: "TEST_ENUM_VALUE_C",
value: 3,
},
{
name: "TEST_DEFAULT_ENUM_VALUE",
value: 4,
},
],
},
};
const entityJson = {
testProperty: "TEST_NO_DATA_ENUM_VALUE",
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
expect(value).toBe("TEST_DEFAULT_ENUM_VALUE");
});

it("obtains a value for a vec3 float32 value with offset in property definition", function () {
const testMetadataClass: MetadataClass = {
properties: {
Expand All @@ -77,11 +133,13 @@ describe("metadata/MetadataEntityModel", function () {
},
},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: [3.0, 4.0, 5.0],
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
Expand All @@ -99,11 +157,13 @@ describe("metadata/MetadataEntityModel", function () {
},
},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: [3.0, 4.0, 5.0],
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
Expand All @@ -122,11 +182,13 @@ describe("metadata/MetadataEntityModel", function () {
},
},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: [3.0, 4.0, 5.0],
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
Expand All @@ -148,8 +210,10 @@ describe("metadata/MetadataEntityModel", function () {
testProperty: [3.0, 4.0, 5.0],
scale: [2.0, 3.0, 4.0],
};
const testMetadataEnums = {};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
Expand All @@ -167,12 +231,14 @@ describe("metadata/MetadataEntityModel", function () {
},
},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: [3.0, 4.0, 5.0],
offset: [1.0, 2.0, 3.0],
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
Expand All @@ -190,12 +256,14 @@ describe("metadata/MetadataEntityModel", function () {
},
},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: [3.0, 4.0, 5.0],
offset: [1.0, 2.0, 3.0],
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
Expand All @@ -213,12 +281,14 @@ describe("metadata/MetadataEntityModel", function () {
},
},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: [3.0, 4.0, 5.0],
scale: [2.0, 3.0, 4.0],
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
Expand All @@ -237,13 +307,15 @@ describe("metadata/MetadataEntityModel", function () {
},
},
};
const testMetadataEnums = {};
const entityJson = {
testProperty: [3.0, 4.0, 5.0],
offset: [1.0, 2.0, 3.0],
scale: [2.0, 3.0, 4.0],
};
const entity = MetadataEntityModels.createFromClass(
testMetadataClass,
testMetadataEnums,
entityJson
);
const value = entity.getPropertyValue("testProperty");
Expand Down
2 changes: 1 addition & 1 deletion specs/metadata/PropertyTableModelsSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ClassProperty } from "../../src/structure/Metadata/ClassProperty";
* - They check whether the elements of the input data and the
* values from the entity model are generically equal.
*/
describe("metadata/PropertyTableModelSpec", function () {
describe("metadata/PropertyTableModelsSpec", function () {
const epsilon = 0.000001;

it("correctly represents example_INT16_SCALAR", function () {
Expand Down
Loading
Loading