{"size": 1821, "ext": "js", "max_stars_repo_path": "test/scene/structure/from-aframe-elements.js", "max_stars_repo_name": "PeterPenz91/3dio-js", "max_stars_repo_stars_event_min_datetime": "2017-07-14T17:50:09.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T15:39:03.000Z", "max_issues_repo_path": "test/scene/structure/from-aframe-elements.js", "max_issues_repo_name": "PeterPenz91/3dio-js", "max_issues_repo_issues_event_min_datetime": "2017-07-14T18:39:56.000Z", "max_issues_repo_issues_event_max_datetime": "2020-02-07T15:33:11.000Z", "max_forks_repo_path": "test/scene/structure/from-aframe-elements.js", "max_forks_repo_name": "PeterPenz91/3dio-js", "max_forks_repo_forks_event_min_datetime": "2017-08-07T16:02:39.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-09T07:17:53.000Z"}
{"max_stars_count": 267, "max_issues_count": 119, "max_forks_count": 73, "avg_line_length": 37.1632653061, "max_line_length": 106, "alphanum_fraction": 0.686985173}
import fromAframeElements from '../../../src/scene/structure/from-aframe-elements.js';
import { stringToCoordinate, parseComponent } from '../../../src/scene/structure/from-aframe-elements.js';

test('a-entity to sceneStructure', () => {
  const el = document.createElement('a-entity')
  el.setAttribute('io3d-wall', 'w: 0.15; l: 4; h: 2')
  el.setAttribute('position', '2 0 -5')
  el.setAttribute('rotation', '0 0 0')
  el.setAttribute('io3d-uuid', '7078987a-d67c-4d01-bd7d-a3c4bb51244b')
  const sceneStructure = fromAframeElements(el)
  expect(sceneStructure.l).toBe(4)
  expect(sceneStructure.w).toBe(0.15)
  expect(sceneStructure.x).toBe(2)
  expect(sceneStructure.z).toBe(-5)
  expect(sceneStructure.id).toBe('7078987a-d67c-4d01-bd7d-a3c4bb51244b')
});

test('a-entity children to sceneStructure', () => {
  const el = document.createElement('a-entity')
  el.setAttribute('io3d-wall', 'w: 0.15; l: 4; h: 2')
  el.setAttribute('position', '2 0 -5')
  el.setAttribute('rotation', '0 0 0')
  el.setAttribute('io3d-uuid', '7078987a-d67c-4d01-bd7d-a3c4bb51244b')
  const doorEl = document.createElement('a-entity')
  doorEl.setAttribute('io3d-door', 'l: 1.2; hinge: left; side: front')
  el.appendChild(doorEl)
  const sceneStructure = fromAframeElements(el)
  const children = sceneStructure.children
  expect(children.length).toBe(1)
  expect(children[0].l).toBe(1.2)
  expect(children[0].hinge).toBe('left')
});

test('stringToCoordinate', () => {
  const str = '12 0.12 0'
  const obj = stringToCoordinate(str)
  expect(obj.x).toBe(12)
  expect(obj.y).toBe(0.12)
  expect(obj.z).toBe(0)
});

test('parse component', () => {
  const str = 'w: 0.15; hinge: left; h: 2'
  const type = 'door'
  const obj = parseComponent(str, type)
  expect(obj.w).toBe(0.15)
  expect(obj.hinge).toBe('left')
  expect(obj.h).toBe(2)
});