1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { MetadataEnum, MetadataType } from "../../Source/Cesium.js";
describe("Scene/MetadataEnum", function () {
it("creates enum with default values", function () {
var colorEnum = new MetadataEnum({
id: "color",
enum: {
values: [
{
name: "RED",
value: 0,
},
{
name: "GREEN",
value: 1,
},
{
name: "BLUE",
value: 2,
},
],
},
});
expect(colorEnum.values[0].name).toBe("RED");
expect(colorEnum.values[1].name).toBe("GREEN");
expect(colorEnum.values[2].name).toBe("BLUE");
expect(colorEnum.valueType).toBe(MetadataType.UINT16);
expect(colorEnum.id).toBe("color");
expect(colorEnum.name).toBeUndefined();
expect(colorEnum.description).toBeUndefined();
expect(colorEnum.extras).toBeUndefined();
expect(colorEnum.extensions).toBeUndefined();
});
it("creates enum", function () {
var extras = {
gain: 0.5,
offset: 0.1,
};
var extensions = {
EXT_other_extension: {},
};
var colorEnum = new MetadataEnum({
id: "color",
enum: {
name: "Color",
description: "Common colors",
extras: extras,
extensions: extensions,
valueType: MetadataType.UINT64,
values: [
{
name: "RED",
value: 0,
},
{
name: "GREEN",
value: 1,
},
{
name: "BLUE",
value: 2,
},
],
},
});
expect(colorEnum.values[0].name).toBe("RED");
expect(colorEnum.values[1].name).toBe("GREEN");
expect(colorEnum.values[2].name).toBe("BLUE");
expect(colorEnum.valueType).toBe(MetadataType.UINT64);
expect(colorEnum.id).toBe("color");
expect(colorEnum.name).toBe("Color");
expect(colorEnum.description).toBe("Common colors");
expect(colorEnum.extras).toBe(extras);
expect(colorEnum.extensions).toBe(extensions);
});
it("constructor throws without id", function () {
expect(function () {
return new MetadataEnum({
enum: {
values: [
{
name: "RED",
value: 0,
},
],
},
});
}).toThrowDeveloperError();
});
it("constructor throws without enum", function () {
expect(function () {
return new MetadataEnum({
id: "enumId",
});
}).toThrowDeveloperError();
});
});