1
0
Fork 0
spacetac/src/ui/common/ParticleBuilder.spec.ts

34 lines
1.4 KiB
TypeScript
Raw Normal View History

2017-09-24 22:23:22 +00:00
module TK.SpaceTac.UI.Specs {
2017-10-26 21:47:13 +00:00
testing("ParticleBuilder", test => {
2017-06-04 20:26:11 +00:00
let testgame = setupEmptyView();
2017-10-26 21:47:13 +00:00
test.case("builds composed particles", check => {
2017-10-09 21:13:56 +00:00
let builder = new ParticleBuilder(testgame.view);
2017-06-04 20:26:11 +00:00
let particle = builder.build([
new ParticleConfig(ParticleShape.ROUND, ParticleColor.BLUE, 2, 1, 45, 10, -20),
new ParticleConfig(ParticleShape.DISK_HALO, ParticleColor.WHITE, 0.5, 1, 0, 5, 0)
]);
2017-10-26 21:47:13 +00:00
check.equals(particle instanceof Phaser.Image, true);
check.equals(particle.data.frame, 4);
check.equals(particle.data.key, "common-particles");
check.equals(particle.scale.x, 2);
check.equals(particle.scale.y, 2);
check.equals(particle.x, 10);
check.equals(particle.y, -20);
check.equals(particle.angle, 45);
2017-06-04 20:26:11 +00:00
2017-10-26 21:47:13 +00:00
check.equals(particle.children.length, 1);
2017-06-04 20:26:11 +00:00
let subparticle = <Phaser.Image>particle.getChildAt(0);
2017-10-26 21:47:13 +00:00
check.equals(subparticle instanceof Phaser.Image, true);
check.equals(subparticle.data.frame, 16);
check.equals(subparticle.data.key, "common-particles");
check.equals(subparticle.scale.x, 0.25);
check.equals(subparticle.scale.y, 0.25);
check.equals(subparticle.x, 2.5);
check.equals(subparticle.y, 0);
check.equals(subparticle.angle, -45);
2017-06-04 20:26:11 +00:00
});
});
}