Quellcode durchsuchen

Add lights es6 unit tests

Tristan VALCKE vor 7 Jahren
Ursprung
Commit
43b15713fc

+ 59 - 0
test/unit/src/lights/AmbientLight.tests.js

@@ -0,0 +1,59 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ * @author moraxy / https://github.com/moraxy
+ */
+/* global QUnit */
+
+import { AmbientLight } from '../../../../src/lights/AmbientLight';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'ArrowHelper', ( hooks ) => {
+
+		var lights = undefined;
+		hooks.beforeEach( function () {
+
+			const parameters = {
+				color: 0xaaaaaa,
+				intensity: 0.5
+			};
+
+			lights = [
+				new AmbientLight(),
+				new AmbientLight( parameters.color ),
+				new AmbientLight( parameters.color, parameters.intensity )
+			];
+
+		} );
+
+		// INHERITANCE
+		QUnit.test( "Extending", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// PUBLIC STUFF
+		QUnit.test( "isAmbiantLight", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// OTHERS
+		QUnit.test( 'Standard light tests', ( assert ) => {
+
+			runStdLightTests( assert, lights );
+
+		} );
+
+	} );
+
+} );

+ 65 - 0
test/unit/src/lights/DirectionalLight.tests.js

@@ -0,0 +1,65 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ * @author moraxy / https://github.com/moraxy
+ */
+/* global QUnit */
+
+import { DirectionalLight } from '../../../../src/lights/DirectionalLight';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'DirectionalLight', ( hooks ) => {
+
+		var lights = undefined;
+		hooks.beforeEach( function () {
+
+			const parameters = {
+				color: 0xaaaaaa,
+				intensity: 0.8
+			};
+
+			lights = [
+				new DirectionalLight(),
+				new DirectionalLight( parameters.color ),
+				new DirectionalLight( parameters.color, parameters.intensity )
+			];
+
+		} );
+
+		// INHERITANCE
+		QUnit.test( "Extending", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// PUBLIC STUFF
+		QUnit.test( "isDirectionalLight", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		QUnit.test( "copy", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// OTHERS
+		QUnit.test( 'Standard light tests', ( assert ) => {
+
+			runStdLightTests( assert, lights );
+
+		} );
+
+	} );
+
+} );

+ 69 - 0
test/unit/src/lights/DirectionalLightShadow.tests.js

@@ -0,0 +1,69 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ * @author moraxy / https://github.com/moraxy
+ */
+/* global QUnit */
+
+import { DirectionalLightShadow } from '../../../../src/lights/DirectionalLightShadow';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'DirectionalLightShadow', () => {
+
+		// INHERITANCE
+		QUnit.test( "Extending", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// OTHERS
+		QUnit.test( "clone/copy", ( assert ) => {
+
+			var a = new DirectionalLightShadow();
+			var b = new DirectionalLightShadow();
+			var c;
+
+			assert.notDeepEqual( a, b, "Newly instanced shadows are not equal" );
+
+			c = a.clone();
+			assert.smartEqual( a, c, "Shadows are identical after clone()" );
+
+			c.mapSize.set( 1024, 1024 );
+			assert.notDeepEqual( a, c, "Shadows are different again after change" );
+
+			b.copy( a );
+			assert.smartEqual( a, b, "Shadows are identical after copy()" );
+
+			b.mapSize.set( 512, 512 );
+			assert.notDeepEqual( a, b, "Shadows are different again after change" );
+
+		} );
+
+		QUnit.test( "toJSON", ( assert ) => {
+
+			var light = new DirectionalLight();
+			var shadow = new DirectionalLightShadow();
+
+			shadow.bias = 10;
+			shadow.radius = 5;
+			shadow.mapSize.set( 1024, 1024 );
+			light.shadow = shadow;
+
+			var json = light.toJSON();
+			var newLight = new ObjectLoader().parse( json );
+
+			assert.smartEqual( newLight.shadow, light.shadow, "Reloaded shadow is identical to the original one" );
+
+		} );
+
+	} );
+
+} );

+ 67 - 0
test/unit/src/lights/HemisphereLight.tests.js

@@ -0,0 +1,67 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ * @author moraxy / https://github.com/moraxy
+ */
+/* global QUnit */
+
+import { HemisphereLight } from '../../../../src/lights/HemisphereLight';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'HemisphereLight', ( hooks ) => {
+
+		var lights = undefined;
+		hooks.beforeEach( function () {
+
+			const parameters = {
+				skyColor: 0x123456,
+				groundColor: 0xabc012,
+				intensity: 0.6
+			};
+
+			lights = [
+				new HemisphereLight(),
+				new HemisphereLight( parameters.skyColor ),
+				new HemisphereLight( parameters.skyColor, parameters.groundColor ),
+				new HemisphereLight( parameters.skyColor, parameters.groundColor, parameters.intensity ),
+			];
+
+		} );
+
+		// INHERITANCE
+		QUnit.test( "Extending", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// PUBLIC STUFF
+		QUnit.test( "isHemisphereLight", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		QUnit.test( "copy", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// OTHERS
+		QUnit.test( 'Standard light tests', ( assert ) => {
+
+			runStdLightTests( assert, lights );
+
+		} );
+
+	} );
+
+} );

+ 70 - 0
test/unit/src/lights/Light.tests.js

@@ -0,0 +1,70 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ */
+/* global QUnit */
+
+import { Light } from '../../../../src/lights/Light';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'Light', ( hooks ) => {
+
+		var lights = undefined;
+		hooks.beforeEach( function () {
+
+			const parameters = {
+				color: 0xaaaaaa,
+				intensity: 0.5
+			};
+
+			lights = [
+				new Light(),
+				new Light( parameters.color ),
+				new Light( parameters.color, parameters.intensity )
+			];
+
+		} );
+
+		// INHERITANCE
+		QUnit.test( "Extending", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// PUBLIC STUFF
+		QUnit.test( "isLight", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		QUnit.test( "copy", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		QUnit.test( "toJSON", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// OTHERS
+		QUnit.test( 'Standard light tests', ( assert ) => {
+
+			runStdLightTests( assert, lights );
+
+		} );
+
+	} );
+
+} );

+ 52 - 0
test/unit/src/lights/LightShadow.tests.js

@@ -0,0 +1,52 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ * @author moraxy / https://github.com/moraxy
+ */
+/* global QUnit */
+
+import { LightShadow } from '../../../../src/lights/LightShadow';
+import { OrthographicCamera } from '../../../../src/cameras/OrthographicCamera';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'LightShadow', () => {
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// PUBLIC STUFF
+		QUnit.test( "clone/copy", ( assert ) => {
+
+			var a = new LightShadow( new OrthographicCamera( - 5, 5, 5, - 5, 0.5, 500 ) );
+			var b = new LightShadow( new OrthographicCamera( - 3, 3, 3, - 3, 0.3, 300 ) );
+			var c;
+
+			assert.notDeepEqual( a, b, "Newly instanced shadows are not equal" );
+
+			c = a.clone();
+			assert.smartEqual( a, c, "Shadows are identical after clone()" );
+
+			c.mapSize.set( 256, 256 );
+			assert.notDeepEqual( a, c, "Shadows are different again after change" );
+
+			b.copy( a );
+			assert.smartEqual( a, b, "Shadows are identical after copy()" );
+
+			b.mapSize.set( 512, 512 );
+			assert.notDeepEqual( a, b, "Shadows are different again after change" );
+
+		} );
+
+		QUnit.test( "toJSON", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+	} );
+
+} );

+ 86 - 0
test/unit/src/lights/PointLight.tests.js

@@ -0,0 +1,86 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ * @author moraxy / https://github.com/moraxy
+ */
+/* global QUnit */
+
+import { PointLight } from '../../../../src/lights/PointLight';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'PointLight', ( hooks ) => {
+
+		var lights = undefined;
+		hooks.beforeEach( function () {
+
+			const parameters = {
+				color: 0xaaaaaa,
+				intensity: 0.5,
+				distance: 100,
+				decay: 2
+			};
+
+			lights = [
+				new PointLight(),
+				new PointLight( parameters.color ),
+				new PointLight( parameters.color, parameters.intensity ),
+				new PointLight( parameters.color, parameters.intensity, parameters.distance ),
+				new PointLight( parameters.color, parameters.intensity, parameters.distance, parameters.decay )
+			];
+
+		} );
+
+		// INHERITANCE
+		QUnit.test( "Extending", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// PROPERTIES
+		QUnit.test( "power", ( assert ) => {
+
+			var a = new PointLight( 0xaaaaaa );
+
+			a.intensity = 100;
+			assert.numEqual( a.power, 100 * Math.PI * 4, "Correct power for an intensity of 100" );
+
+			a.intensity = 40;
+			assert.numEqual( a.power, 40 * Math.PI * 4, "Correct power for an intensity of 40" );
+
+			a.power = 100;
+			assert.numEqual( a.intensity, 100 / ( 4 * Math.PI ), "Correct intensity for a power of 100" );
+
+		} );
+
+		// PUBLIC STUFF
+		QUnit.test( "isPointLight", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		QUnit.test( "copy", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// OTHERS
+		QUnit.test( 'Standard light tests', ( assert ) => {
+
+			runStdLightTests( assert, lights );
+
+		} );
+
+
+	} );
+
+} );

+ 74 - 0
test/unit/src/lights/RectAreaLight.tests.js

@@ -0,0 +1,74 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ * @author moraxy / https://github.com/moraxy
+ */
+/* global QUnit */
+
+import { RectAreaLight } from '../../../../src/lights/RectAreaLight';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'RectAreaLight', ( hooks ) => {
+
+		var lights = undefined;
+		hooks.beforeEach( function () {
+
+			const parameters = {
+				color: 0xaaaaaa,
+				intensity: 0.5,
+				width: 100,
+				height: 50
+			};
+
+			lights = [
+				new RectAreaLight( parameters.color ),
+				new RectAreaLight( parameters.color, parameters.intensity ),
+				new RectAreaLight( parameters.color, parameters.intensity, parameters.width ),
+				new RectAreaLight( parameters.color, parameters.intensity, parameters.width, parameters.height )
+			];
+
+		} );
+
+		// INHERITANCE
+		QUnit.test( "Extending", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// PUBLIC STUFF
+		QUnit.test( "isRectAreaLight", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		QUnit.test( "copy", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		QUnit.test( "toJSON", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// OTHERS
+		QUnit.test( 'Standard light tests', ( assert ) => {
+
+			runStdLightTests( assert, lights );
+
+		} );
+
+	} );
+
+} );

+ 90 - 0
test/unit/src/lights/SpotLight.tests.js

@@ -0,0 +1,90 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ * @author moraxy / https://github.com/moraxy
+ */
+/* global QUnit */
+
+import { SpotLight } from '../../../../src/lights/SpotLight';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'SpotLight', ( hooks ) => {
+
+		var lights = undefined;
+		hooks.beforeEach( function () {
+
+			const parameters = {
+				color: 0xaaaaaa,
+				intensity: 0.5,
+				distance: 100,
+				angle: 0.8,
+				penumbra: 8,
+				decay: 2
+			};
+
+			lights = [
+				new SpotLight( parameters.color ),
+				new SpotLight( parameters.color, parameters.intensity ),
+				new SpotLight( parameters.color, parameters.intensity, parameters.distance ),
+				new SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle ),
+				new SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle, parameters.penumbra ),
+				new SpotLight( parameters.color, parameters.intensity, parameters.distance, parameters.angle, parameters.penumbra, parameters.decay ),
+			];
+
+		} );
+
+		// INHERITANCE
+		QUnit.test( "Extending", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// PROPERTIES
+		QUnit.test( "power", ( assert ) => {
+
+			var a = new SpotLight( 0xaaaaaa );
+
+			a.intensity = 100;
+			assert.numEqual( a.power, 100 * Math.PI, "Correct power for an intensity of 100" );
+
+			a.intensity = 40;
+			assert.numEqual( a.power, 40 * Math.PI, "Correct power for an intensity of 40" );
+
+			a.power = 100;
+			assert.numEqual( a.intensity, 100 / Math.PI, "Correct intensity for a power of 100" );
+
+		} );
+
+		// PUBLIC STUFF
+		QUnit.test( "isSpotLight", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		QUnit.test( "copy", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// OTHERS
+		QUnit.test( 'Standard light tests', ( assert ) => {
+
+			runStdLightTests( assert, lights );
+
+		} );
+
+
+
+	} );
+
+} );

+ 84 - 0
test/unit/src/lights/SpotLightShadow.tests.js

@@ -0,0 +1,84 @@
+/**
+ * @author TristanVALCKE / https://github.com/Itee
+ * @author moraxy / https://github.com/moraxy
+ */
+/* global QUnit */
+
+import { SpotLightShadow } from '../../../../src/lights/SpotLightShadow';
+import { SpotLight } from '../../../../src/lights/SpotLight';
+import { ObjectLoader } from '../../../../src/loaders/ObjectLoader';
+
+export default QUnit.module( 'Lights', () => {
+
+	QUnit.module.todo( 'SpotLightShadow', () => {
+
+		// INHERITANCE
+		QUnit.test( "Extending", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// INSTANCING
+		QUnit.test( "Instancing", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// PUBLIC STUFF
+		QUnit.test( "isSpotLightShadow", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		QUnit.test( "update", ( assert ) => {
+
+			assert.ok( false, "everything's gonna be alright" );
+
+		} );
+
+		// OTHERS
+		QUnit.test( "clone/copy", ( assert ) => {
+
+			var a = new SpotLightShadow();
+			var b = new SpotLightShadow();
+			var c;
+
+			assert.notDeepEqual( a, b, "Newly instanced shadows are not equal" );
+
+			c = a.clone();
+			assert.smartEqual( a, c, "Shadows are identical after clone()" );
+
+			c.mapSize.set( 256, 256 );
+			assert.notDeepEqual( a, c, "Shadows are different again after change" );
+
+			b.copy( a );
+			assert.smartEqual( a, b, "Shadows are identical after copy()" );
+
+			b.mapSize.set( 512, 512 );
+			assert.notDeepEqual( a, b, "Shadows are different again after change" );
+
+		} );
+
+		QUnit.test( "toJSON", ( assert ) => {
+
+			var light = new SpotLight();
+			var shadow = new SpotLightShadow();
+
+			shadow.bias = 10;
+			shadow.radius = 5;
+			shadow.mapSize.set( 128, 128 );
+			light.shadow = shadow;
+
+			var json = light.toJSON();
+			var newLight = new ObjectLoader().parse( json );
+
+			assert.smartEqual( newLight.shadow, light.shadow, "Reloaded shadow is equal to the original one" );
+
+		} );
+
+	} );
+
+} );