Browse Source

Added ParticleHelper unit tests

Christopher Yovanovitch 7 years ago
parent
commit
0b7c30154e
1 changed files with 34 additions and 4 deletions
  1. 34 4
      tests/unit/babylon/src/Helpers/babylon.particleHelper.tests.ts

+ 34 - 4
tests/unit/babylon/src/Helpers/babylon.particleHelper.tests.ts

@@ -31,10 +31,40 @@ describe('Babylon Particle Helper', function () {
       });
       });
   });
   });
 
 
-  describe('#JSON', () => {
-      it('creates a fire particle system', () => {
-          const scene = new BABYLON.Scene(subject);
-          //
+  describe('#ParticleHelper.CreateAsync', () => {
+      let scene: BABYLON.Scene;
+      let emitter: BABYLON.Mesh;
+
+      beforeEach(() => {
+        scene = new BABYLON.Scene(subject);
+        emitter = BABYLON.Mesh.CreateSphere("sphere", 10, 5, scene);
+      });
+
+      it('creates a fire particle system', (done) => {
+        BABYLON.ParticleHelper.CreateAsync("fire", emitter, scene)
+            .then((system) => {
+                expect(system).to.be.instanceof(BABYLON.ParticleSystem);
+                done();
+            })
+            .catch((error) => { throw new Error("was not supposed to fail"); });
       });
       });
+
+      it('creates a smoke particle system', (done) => {
+        BABYLON.ParticleHelper.CreateAsync("smoke", emitter, scene)
+            .then((system) => {
+                expect(system).to.be.instanceof(BABYLON.ParticleSystem);
+                done();
+            })
+            .catch((error) => { throw new Error("was not supposed to fail"); });
+    });
+
+      it('rejects the creation of the particle system', (done) => {
+        BABYLON.ParticleHelper.CreateAsync("test", emitter, scene)
+            .then(() => { throw new Error("was not supposed to succeed"); })
+            .catch((error) => {
+                expect(error).to.equals("An error occured while the creation of your particle system. Check if your type 'test' exists.");
+                done();
+            });
+    });
   });
   });
 });
 });