How to use the excalibur-jasmine.ensureImagesLoaded function in excalibur-jasmine

To help you get started, we’ve selected a few excalibur-jasmine examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github excaliburjs / Excalibur / src / spec / LabelSpec.ts View on Github external
it('can change color', (done) => {
    label.text = 'some blue text';
    label.fontSize = 30;
    label.color = ex.Color.Blue.clone();

    expect(label.color.toString()).toBe(ex.Color.Blue.toString());

    label.update(engine, 100);
    label.draw(engine.ctx, 100);
    expect(label.color.toString()).toBe(ex.Color.Blue.toString());

    ensureImagesLoaded(engine.canvas, 'src/spec/images/LabelSpec/bluetext.png').then(([canvas, image]) => {
      expect(canvas).toEqualImage(image, 1);
      done();
    });
  });
github excaliburjs / Excalibur / src / spec / CollisionShapeSpec.ts View on Github external
it('can be drawn with actor', (done) => {
      const edgeActor = new ex.Actor({
        pos: new ex.Vector(150, 100),
        color: ex.Color.Blue,
        body: new ex.Body({
          collider: new ex.Collider({
            shape: ex.Shape.Edge(ex.Vector.Zero, new ex.Vector(300, 300))
          })
        })
      });

      scene.add(edgeActor);
      scene.draw(engine.ctx, 100);

      ensureImagesLoaded(engine.canvas, 'src/spec/images/CollisionShapeSpec/edge.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
    });
github excaliburjs / Excalibur / src / spec / LabelSpec.ts View on Github external
it('to enable bold text', (done) => {
    label.text = 'some bold text';
    label.fontFamily = 'Arial';
    label.fontSize = 30;
    label.color = ex.Color.Black;
    label.bold = true;

    label.draw(engine.ctx, 100);
    ensureImagesLoaded(engine.canvas, 'src/spec/images/LabelSpec/boldtext-linux.png').then(([canvas, image]) => {
      expect(canvas).toEqualImage(image, 0.98);
      done();
    });
  });
github excaliburjs / Excalibur / src / spec / SpriteSpec.ts View on Github external
x: 0,
        y: 0,
        width: 62,
        height: 64,
        rotation: 0,
        anchor: new ex.Vector(0.0, 0.0),
        scale: new ex.Vector(1, 1),
        flipVertical: false,
        flipHorizontal: false
      });

      sprite.lighten();

      sprite.draw(engine.ctx, 0, 0);

      ensureImagesLoaded(engine.canvas, 'src/spec/images/SpriteSpec/icon-lightened.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
    });
  });
github excaliburjs / Excalibur / src / spec / CameraSpec.ts View on Github external
engine.currentScene.camera.zoom(0.2, 1000).then(() => {
        ensureImagesLoaded(engine.canvas, 'src/spec/images/CameraSpec/zoomout.png').then(([canvas, image]) => {
          expect(canvas).toEqualImage(image, 0.995);
          done();
        });
      });
    });
github excaliburjs / Excalibur / src / spec / CameraSpec.ts View on Github external
engine.currentScene.camera.zoom(5, 1000).then(() => {
        ensureImagesLoaded(engine.canvas, 'src/spec/images/CameraSpec/zoomin.png').then(([canvas, image]) => {
          expect(canvas).toEqualImage(image, 0.995);
          done();
        });
      });
    });
github excaliburjs / Excalibur / src / spec / SpriteSpec.ts View on Github external
x: 0,
        y: 0,
        width: 62,
        height: 64,
        rotation: 0,
        anchor: new ex.Vector(0.0, 0.0),
        scale: new ex.Vector(1, 1),
        flipVertical: false,
        flipHorizontal: false
      });

      sprite.invert();

      sprite.draw(engine.ctx, 0, 0);

      ensureImagesLoaded(engine.canvas, 'src/spec/images/SpriteSpec/icon-inverted.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
    });
  });
github excaliburjs / Excalibur / src / spec / ParticleSpec.ts View on Github external
particleSprite: null,
      emitterType: ex.EmitterType.Circle,
      radius: 20,
      particleRotationalVelocity: 3,
      randomRotation: false,
      random: new ex.Random(1337)
    });

    emitter.emitParticles(10);
    emitter.update(engine, 100);
    emitter.update(engine, 100);
    emitter.update(engine, 100);

    emitter.draw(engine.ctx);

    ensureImagesLoaded(engine.canvas, 'src/spec/images/ParticleSpec/Particles.png').then(([canvas, image]) => {
      expect(canvas).toEqualImage(image);
      done();
    });
  });
});
github excaliburjs / Excalibur / src / spec / SpriteSpec.ts View on Github external
x: 0,
        y: 0,
        width: 62,
        height: 64,
        rotation: 0,
        anchor: new ex.Vector(0.0, 0.0),
        scale: new ex.Vector(1, 1),
        flipVertical: false,
        flipHorizontal: false
      });

      sprite.darken();

      sprite.draw(engine.ctx, 0, 0);

      ensureImagesLoaded(engine.canvas, 'src/spec/images/SpriteSpec/icon-darkened.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
    });
  });
github excaliburjs / Excalibur / src / spec / TileMapSpec.ts View on Github external
y: 30,
        cellWidth: 64,
        cellHeight: 48,
        rows: 3,
        cols: 7
      });
      const spriteTiles = new ex.SpriteSheet(texture, 1, 1, 64, 48);
      tm.registerSpriteSheet('default', spriteTiles);
      tm.data.forEach(function(cell: ex.Cell) {
        cell.solid = true;
        cell.pushSprite(new ex.TileSprite('default', 0));
      });

      tm.draw(engine.ctx, 100);

      ensureImagesLoaded(engine.canvas, 'src/spec/images/TileMapSpec/TileMap.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
    });
  });

excalibur-jasmine

Jasmine matchers for testing excalibur

BSD-2-Clause
Latest version published 10 days ago

Package Health Score

63 / 100
Full package analysis

Popular excalibur-jasmine functions