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

38 lines
1.5 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-10-29 21:08:55 +00:00
let testgame = setupEmptyView(test);
2017-06-04 20:26:11 +00:00
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)
]);
2018-05-15 14:57:45 +00:00
check.equals(particle.length, 2);
2017-06-04 20:26:11 +00:00
2018-05-15 14:57:45 +00:00
let child = particle.list[0];
if (check.instance(child, Phaser.GameObjects.Image, "first particle is an image")) {
check.equals((<any>child.data).frame, 4);
check.equals((<any>child.data).key, "common-particles");
check.equals(child.scaleX, 2);
check.equals(child.scaleY, 2);
check.equals(child.x, 10);
check.equals(child.y, -20);
check.equals(child.angle, 45);
}
child = particle.list[1];
if (check.instance(child, Phaser.GameObjects.Image, "second particle is an image")) {
check.equals((<any>child.data).frame, 16);
check.equals((<any>child.data).key, "common-particles");
check.equals(child.scaleX, 0.5);
check.equals(child.scaleY, 0.5);
check.equals(child.x, 5);
check.equals(child.y, 0);
check.equals(child.angle, 0);
}
2017-06-04 20:26:11 +00:00
});
});
}