2022-03-11 05:08:59 -06:00
|
|
|
// import {Flecks} from '@flecks/core';
|
|
|
|
// import {expect} from 'chai';
|
2021-01-03 00:57:51 -06:00
|
|
|
|
2022-03-11 05:08:59 -06:00
|
|
|
// let flecks;
|
|
|
|
// let Entity;
|
|
|
|
// let EntityList;
|
|
|
|
// beforeEach(async () => {
|
|
|
|
// flecks = Flecks.mock({
|
|
|
|
// '@avocado/entity': require('../src'),
|
|
|
|
// '@avocado/resource': require('@avocado/resource'),
|
|
|
|
// '@avocado/traits': require('@avocado/traits'),
|
|
|
|
// });
|
|
|
|
// await Promise.all(flecks.invokeFlat('@flecks/core/starting'));
|
|
|
|
// ({Entity, EntityList} = flecks.get('$avocado/resource.resources'));
|
|
|
|
// });
|
|
|
|
// describe('Mobile', () => {
|
|
|
|
// let entity;
|
|
|
|
// beforeEach(async () => {
|
|
|
|
// entity = await Entity.load({
|
|
|
|
// traits: {
|
|
|
|
// Mobile: {},
|
|
|
|
// Positioned: {},
|
|
|
|
// },
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// it('exists', async () => {
|
|
|
|
// expect(entity.is('Mobile')).to.be.true;
|
|
|
|
// });
|
|
|
|
// it('can request movement', async () => {
|
|
|
|
// entity.speed = 100;
|
|
|
|
// entity.requestMovement([1, 0]);
|
|
|
|
// entity.tick(1);
|
|
|
|
// expect(entity.position).to.deep.equal([100, 0]);
|
|
|
|
// entity.tick(1);
|
|
|
|
// expect(entity.position).to.deep.equal([100, 0]);
|
|
|
|
// entity.isMobile = false;
|
|
|
|
// entity.requestMovement([1, 0]);
|
|
|
|
// entity.tick(1);
|
|
|
|
// expect(entity.position).to.deep.equal([100, 0]);
|
|
|
|
// });
|
|
|
|
// it('can force movement', async () => {
|
|
|
|
// expect(entity.speed).to.equal(0);
|
|
|
|
// entity.forceMovement([10, 0]);
|
|
|
|
// expect(entity.position).to.deep.equal([10, 0]);
|
|
|
|
// });
|
|
|
|
// it('can move for a time', async () => {
|
|
|
|
// entity.speed = 10;
|
|
|
|
// const tickingPromise = entity.moveFor([1, 0], 1);
|
|
|
|
// entity.addTickingPromise(tickingPromise);
|
|
|
|
// expect(entity.position).to.deep.equal([0, 0]);
|
|
|
|
// entity.tick(0.25);
|
|
|
|
// expect(entity.position).to.deep.equal([2.5, 0]);
|
|
|
|
// entity.tick(0.25);
|
|
|
|
// expect(entity.position).to.deep.equal([5, 0]);
|
|
|
|
// entity.tick(0.5);
|
|
|
|
// expect(entity.position).to.deep.equal([10, 0]);
|
|
|
|
// return tickingPromise;
|
|
|
|
// });
|
|
|
|
// });
|