History

filter getEntity(Multiple)Properties entities unitTest

Thijs Wenker committed 8 years ago

Commit e266e2e1 parent 80beb6c1 file · +45 −0Browse files

Showing the changes to scripts/developer (1 of 1 file). Show all

Unified · Split

scripts/developer/tests/unit_tests/entityUnitTests.js+45−0
@@ -72,4 +72,49 @@ describe('Entity', function() { · 71 unmodified lines
7272 props = Entities.getEntityProperties(boxEntity);
7373 expect(props.lastEdited).toBeGreaterThan(prevLastEdited);
7474 });
75+
76+ it("filtering getEntityProperties seems to work correctly", function() {
77+ var properties = Entities.getEntityProperties(boxEntity, 'position');
78+ expect(properties.id).toBe(boxEntity);
79+ expect(properties.type).toBe(boxProps.type);
80+ expect(properties.position).toBeDefined();
81+ });
82+
83+ it("filtering getMultipleEntityProperties seems to work correctly", function () {
84+ var sphereProps = {
85+ type: 'Sphere',
86+ color: {
87+ red: 255,
88+ green: 255,
89+ blue: 255,
90+ },
91+ position: center,
92+ dimensions: {
93+ x: 1,
94+ y: 1,
95+ z: 1,
96+ },
97+ };
98+ var sphereEntity = Entities.addEntity(sphereProps);
99+
100+ var entityIDs = [boxEntity, sphereEntity];
101+ var filterTypes = 'type';
102+ var propertySets = Entities.getMultipleEntityProperties(entityIDs, filterTypes);
103+ expect(propertySets.length).toBe(entityIDs.length);
104+ expect(propertySets[0].type).toBe(boxProps.type);
105+ expect(Object.keys(propertySets[0]).length).toBe(1);
106+ expect(propertySets[1].type).toBe(sphereProps.type);
107+ expect(Object.keys(propertySets[1]).length).toBe(1);
108+
109+ filterTypes = ['id', 'type'];
110+ propertySets = Entities.getMultipleEntityProperties(entityIDs, filterTypes);
111+ expect(propertySets.length).toBe(entityIDs.length);
112+ expect(Object.keys(propertySets[0]).length).toBe(filterTypes.length);
113+ expect(propertySets[0].type).toBe(boxProps.type);
114+ expect(Object.keys(propertySets[1]).length).toBe(filterTypes.length);
115+ expect(propertySets[1].type).toBe(sphereProps.type);
116+
117+ Entities.deleteEntity(sphereEntity);
118+ });
119+
75120 });