|
| 1 | +import * as THREE from '../../example/jsm/three.module.js'; |
| 2 | +import { getDefaultOptions } from '../../src/default.options.js'; |
| 3 | +import * as KLEE from '../../dist/klee.js'; |
| 4 | + |
| 5 | +describe('KLEE app', function () { |
| 6 | + |
| 7 | + describe('init (THREE, options)', function () { |
| 8 | + |
| 9 | + it('should create a THREE.WebGLRenderer with options and/or default options', () => { |
| 10 | + |
| 11 | + const defaultOptions = getDefaultOptions(THREE); |
| 12 | + const defaultRendererElement = defaultOptions.renderer.domElement; |
| 13 | + const options = { renderer: { properties: { shadowMap: { enabled: false } } } }; |
| 14 | + const optionsShadows = options.renderer.properties.shadowMap.enabled; |
| 15 | + |
| 16 | + KLEE.App.init(THREE, options); |
| 17 | + const renderer = KLEE.App.renderer; |
| 18 | + const rendererElement = renderer.domElement.parentElement.localName; |
| 19 | + const rendererShadows = renderer.shadowMap.enabled; |
| 20 | + |
| 21 | + expect(renderer).to.be.an.instanceof(THREE.WebGLRenderer); |
| 22 | + expect(rendererElement).to.be.equal(defaultRendererElement); |
| 23 | + expect(rendererShadows).to.be.equal(optionsShadows); |
| 24 | + |
| 25 | + renderer.dispose(); |
| 26 | + |
| 27 | + }); |
| 28 | + |
| 29 | + it('throws an error, when no THREE is given', () => { |
| 30 | + |
| 31 | + expect(() => KLEE.App.init()).to.throw(); |
| 32 | + expect(() => KLEE.App.init(2)).to.throw(); |
| 33 | + expect(() => KLEE.App.init('some-string')).to.throw(); |
| 34 | + |
| 35 | + }); |
| 36 | + |
| 37 | + }); |
| 38 | + |
| 39 | + describe('create (options)', function () { |
| 40 | + |
| 41 | + it('should create a THREE object width a THREE method and some args', () => { |
| 42 | + |
| 43 | + const material = { |
| 44 | + type: 'MeshBasicMaterial', |
| 45 | + args: [{ color: 0x00ff00 }] |
| 46 | + }; |
| 47 | + const materialColor = new THREE.Color(material.args[0].color); |
| 48 | + |
| 49 | + const materialObject = KLEE.App.create(material); |
| 50 | + |
| 51 | + expect(materialObject.color).to.be.eql(materialColor); |
| 52 | + expect(materialObject).to.be.an.instanceof(THREE.MeshBasicMaterial); |
| 53 | + |
| 54 | + }); |
| 55 | + |
| 56 | + }); |
| 57 | + |
| 58 | + describe('initSize ()', function () { |
| 59 | + |
| 60 | + it('it should set the size of the renderer and the camera aspect'); |
| 61 | + |
| 62 | + }); |
| 63 | + |
| 64 | + describe('run (callback)', function () { |
| 65 | + |
| 66 | + it('it sets the requestAnimationFrame and runs an optional callback inside'); |
| 67 | + |
| 68 | + }); |
| 69 | + |
| 70 | + describe('error (message)', function () { |
| 71 | + |
| 72 | + it('throws and error with arguments message', () => { |
| 73 | + |
| 74 | + const message = 'Error message'; |
| 75 | + |
| 76 | + expect(() => KLEE.App.error(message)).to.throw(message); |
| 77 | + |
| 78 | + }); |
| 79 | + |
| 80 | + }); |
| 81 | + |
| 82 | + describe('warn (message)', function () { |
| 83 | + |
| 84 | + it('shows a warning in console with message if debugLevel > 0'); |
| 85 | + |
| 86 | + }); |
| 87 | + |
| 88 | + describe('log (message)', function () { |
| 89 | + |
| 90 | + it('shows log in console with message if debugLevel > 1'); |
| 91 | + |
| 92 | + }); |
| 93 | + |
| 94 | + describe('info (message)', function () { |
| 95 | + |
| 96 | + it('shows info in console with message if debugLevel > 2'); |
| 97 | + |
| 98 | + }); |
| 99 | + |
| 100 | + describe('setter', function () { |
| 101 | + |
| 102 | + it('scene, set the THREE.Scene'); |
| 103 | + it('camera, set the THREE.Camera'); |
| 104 | + it('controls, set the THREE.Controls'); |
| 105 | + |
| 106 | + }); |
| 107 | + |
| 108 | + describe('getter', function () { |
| 109 | + |
| 110 | + it('options, returns the options set from init'); |
| 111 | + it('THREE, returns the THREE module set from init'); |
| 112 | + it('scene, returns the generated THREE.Scene'); |
| 113 | + it('camera, returns the generated THREE.Camera'); |
| 114 | + it('controls, returns the generated THREE.Controls'); |
| 115 | + it('renderer, returns the generated THREE.Renderer'); |
| 116 | + |
| 117 | + }); |
| 118 | + |
| 119 | +}); |
0 commit comments