to do: updateResources action, actions test suite
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { buyCard, getTotalBuyingPower, tooExpensive, updateResources } from './buyCardActions';
|
import { buyCard, getTotalBuyingPower, tooExpensive, updateResources } from './buyCardActions';
|
||||||
import { test, expect, describe } from 'vitest';
|
import { test, expect, describe } from 'vitest';
|
||||||
import { expensiveCard, mockPlayerOne, mockPlayerTwo, mockState } from '../../../util/testUtils';
|
import { expensiveCard, midGameCardOne, midGameState, mockPlayerOne, mockPlayerTwo, mockState } from '../../../util/testUtils';
|
||||||
import { useCurrentPlayer } from '../../../util/useCurrentPlayer';
|
import { useCurrentPlayer } from '../../../util/useCurrentPlayer';
|
||||||
|
|
||||||
describe('buy cards', () => {
|
describe('buy cards', () => {
|
||||||
@@ -44,10 +44,10 @@ describe('buy cards', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('updateResources', () => {
|
test('updateResources', () => {
|
||||||
const currentPlayer = useCurrentPlayer(mockState);
|
const currentPlayer = useCurrentPlayer(midGameState);
|
||||||
if (!currentPlayer) return;
|
if (!currentPlayer) return;
|
||||||
|
|
||||||
const { newTradingResources, updatedPlayer } = updateResources(mockState, expensiveCard);
|
const { newTradingResources, updatedPlayer } = updateResources(midGameState, midGameCardOne);
|
||||||
expect(newTradingResources).toBeDefined();
|
expect(newTradingResources).toBeDefined();
|
||||||
expect(updatedPlayer).toBeDefined();
|
expect(updatedPlayer).toBeDefined();
|
||||||
})
|
})
|
||||||
@@ -56,4 +56,7 @@ describe('buy cards', () => {
|
|||||||
const output = 1;
|
const output = 1;
|
||||||
expect(output).toBe(1);
|
expect(output).toBe(1);
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('get chips', () => {})
|
||||||
|
describe('reserve card', () => {})
|
||||||
@@ -44,6 +44,83 @@ export const mockState: AppState = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// mock data for midgame
|
// mock data for midgame
|
||||||
|
export const playerOneMidGame = {
|
||||||
|
...mockPlayerOne,
|
||||||
|
cards: [
|
||||||
|
...mockPlayerOne.cards,
|
||||||
|
{
|
||||||
|
gemValue: "diamond",
|
||||||
|
tier: 1,
|
||||||
|
points: 0,
|
||||||
|
resourceCost: {
|
||||||
|
ruby: 0,
|
||||||
|
sapphire: 0,
|
||||||
|
emerald: 2,
|
||||||
|
diamond: 2,
|
||||||
|
onyx: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gemValue: "diamond",
|
||||||
|
tier: 1,
|
||||||
|
points: 0,
|
||||||
|
resourceCost: {
|
||||||
|
ruby: 0,
|
||||||
|
sapphire: 3,
|
||||||
|
emerald: 0,
|
||||||
|
diamond: 0,
|
||||||
|
onyx: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
inventory: {
|
||||||
|
ruby: 0,
|
||||||
|
sapphire: 0,
|
||||||
|
emerald: 1,
|
||||||
|
diamond: 3,
|
||||||
|
onyx: 1,
|
||||||
|
gold: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const playerTwoMidGame = {
|
||||||
|
...mockPlayerTwo,
|
||||||
|
cards: [
|
||||||
|
...mockPlayerTwo.cards,
|
||||||
|
{
|
||||||
|
gemValue: "ruby",
|
||||||
|
tier: 1,
|
||||||
|
points: 0,
|
||||||
|
resourceCost: {
|
||||||
|
ruby: 3,
|
||||||
|
sapphire: 0,
|
||||||
|
emerald: 0,
|
||||||
|
diamond: 0,
|
||||||
|
onyx: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
gemValue: "ruby",
|
||||||
|
tier: 1,
|
||||||
|
points: 0,
|
||||||
|
resourceCost: {
|
||||||
|
ruby: 0,
|
||||||
|
sapphire: 1,
|
||||||
|
emerald: 1,
|
||||||
|
diamond: 1,
|
||||||
|
onyx: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
inventory: {
|
||||||
|
ruby: 4,
|
||||||
|
sapphire: 0,
|
||||||
|
emerald: 0,
|
||||||
|
diamond: 0,
|
||||||
|
onyx: 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const midGameState: AppState = {
|
export const midGameState: AppState = {
|
||||||
...initialState,
|
...initialState,
|
||||||
gameboard: {
|
gameboard: {
|
||||||
@@ -58,49 +135,33 @@ export const midGameState: AppState = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
round: 4,
|
round: 4,
|
||||||
players: [
|
players: [playerOneMidGame, playerTwoMidGame]
|
||||||
{
|
}
|
||||||
...mockPlayerOne,
|
|
||||||
cards: [
|
export const midGameCardOne: CardData = {
|
||||||
...mockPlayerOne.cards,
|
gemValue: 'ruby',
|
||||||
{
|
tier: 2,
|
||||||
gemValue: "diamond",
|
points: 2,
|
||||||
tier: 1,
|
resourceCost: {
|
||||||
points: 0,
|
ruby: 0,
|
||||||
resourceCost: {
|
sapphire: 0,
|
||||||
ruby: 0,
|
emerald: 0,
|
||||||
sapphire: 0,
|
diamond: 5,
|
||||||
emerald: 2,
|
onyx: 0
|
||||||
diamond: 2,
|
}
|
||||||
onyx: 0
|
}
|
||||||
}
|
|
||||||
},
|
export const midGameCardTwo: CardData = {
|
||||||
{
|
gemValue: 'diamond',
|
||||||
gemValue: "diamond",
|
tier: 2,
|
||||||
tier: 1,
|
points: 2,
|
||||||
points: 0,
|
resourceCost: {
|
||||||
resourceCost: {
|
ruby: 5,
|
||||||
ruby: 0,
|
sapphire: 0,
|
||||||
sapphire: 3,
|
emerald: 0,
|
||||||
emerald: 0,
|
diamond: 0,
|
||||||
diamond: 0,
|
onyx: 0
|
||||||
onyx: 0
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
inventory: {
|
|
||||||
ruby: 0,
|
|
||||||
sapphire: 0,
|
|
||||||
emerald: 1,
|
|
||||||
diamond: 3,
|
|
||||||
onyx: 1,
|
|
||||||
gold: 1
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
...mockPlayerTwo
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// miscellaneous mock data
|
// miscellaneous mock data
|
||||||
|
|||||||
Reference in New Issue
Block a user