refactor: async boop
This commit is contained in:
+12
-12
@@ -170,7 +170,7 @@ describe('Boop - helper functions', () => {
|
||||
});
|
||||
|
||||
describe('applyBoops', () => {
|
||||
it('should boop adjacent kitten away from placed kitten', () => {
|
||||
it('should boop adjacent kitten away from placed kitten', async () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
|
||||
@@ -180,12 +180,12 @@ describe('Boop - helper functions', () => {
|
||||
const whitePart = getParts(state)[1];
|
||||
expect(whitePart.position).toEqual([2, 2]);
|
||||
|
||||
applyBoops(state, 3, 3, 'kitten');
|
||||
await applyBoops(state, 3, 3, 'kitten');
|
||||
|
||||
expect(whitePart.position).toEqual([1, 1]);
|
||||
});
|
||||
|
||||
it('should not boop a cat when a kitten is placed', () => {
|
||||
it('should not boop a cat when a kitten is placed', async () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
|
||||
@@ -193,26 +193,26 @@ describe('Boop - helper functions', () => {
|
||||
const whitePart = getParts(state)[0];
|
||||
whitePart.pieceType = 'cat';
|
||||
|
||||
applyBoops(state, 3, 3, 'kitten');
|
||||
await applyBoops(state, 3, 3, 'kitten');
|
||||
|
||||
expect(whitePart.position).toEqual([3, 3]);
|
||||
});
|
||||
|
||||
it('should remove piece that is booped off the board', () => {
|
||||
it('should remove piece that is booped off the board', async () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
|
||||
placePiece(state, 0, 0, 'white', 'kitten');
|
||||
placePiece(state, 1, 1, 'black', 'kitten');
|
||||
|
||||
applyBoops(state, 1, 1, 'kitten');
|
||||
await applyBoops(state, 1, 1, 'kitten');
|
||||
|
||||
expect(getParts(state).length).toBe(1);
|
||||
expect(getParts(state)[0].player).toBe('black');
|
||||
expect(state.value.players.white.kitten.supply).toBe(8);
|
||||
});
|
||||
|
||||
it('should not boop piece if target cell is occupied', () => {
|
||||
it('should not boop piece if target cell is occupied', async () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
|
||||
@@ -220,7 +220,7 @@ describe('Boop - helper functions', () => {
|
||||
placePiece(state, 2, 1, 'black', 'kitten');
|
||||
placePiece(state, 0, 1, 'black', 'kitten');
|
||||
|
||||
applyBoops(state, 0, 1, 'kitten');
|
||||
await applyBoops(state, 0, 1, 'kitten');
|
||||
|
||||
const whitePart = getParts(state).find(p => p.player === 'white');
|
||||
expect(whitePart).toBeDefined();
|
||||
@@ -229,7 +229,7 @@ describe('Boop - helper functions', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('should boop multiple adjacent pieces', () => {
|
||||
it('should boop multiple adjacent pieces', async () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
|
||||
@@ -237,19 +237,19 @@ describe('Boop - helper functions', () => {
|
||||
placePiece(state, 2, 2, 'black', 'kitten');
|
||||
placePiece(state, 2, 3, 'black', 'kitten');
|
||||
|
||||
applyBoops(state, 3, 3, 'kitten');
|
||||
await applyBoops(state, 3, 3, 'kitten');
|
||||
|
||||
expect(getParts(state)[1].position).toEqual([1, 1]);
|
||||
expect(getParts(state)[2].position).toEqual([1, 3]);
|
||||
});
|
||||
|
||||
it('should not boop the placed piece itself', () => {
|
||||
it('should not boop the placed piece itself', async () => {
|
||||
const { ctx } = createTestContext();
|
||||
const state = getState(ctx);
|
||||
|
||||
placePiece(state, 3, 3, 'white', 'kitten');
|
||||
|
||||
applyBoops(state, 3, 3, 'kitten');
|
||||
await applyBoops(state, 3, 3, 'kitten');
|
||||
|
||||
expect(getParts(state)[0].position).toEqual([3, 3]);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user