preparing to redefine some actions

This commit is contained in:
2022-08-05 14:08:31 -05:00
parent 4de7c30804
commit 9abd8b2667
10 changed files with 1707 additions and 83 deletions

View File

@@ -0,0 +1,82 @@
import { describe, expect, it, test } from "vitest";
import { initialActions } from "../../../util/stateSetters";
import { mockPlayerOne, mockState } from "../../../util/testUtils";
import { AppState, PlayerData } from "../../../util/types";
import { hasMaxChips, validateChips } from "./getChipsActions";
const getChipsState: AppState = {
...mockState,
actions: {
...initialActions,
getChips: {
active: true,
selection: []
}
}
}
describe('get chips', () => {
test('hasMaxChips', () => {
const illegalPlayer: PlayerData = {
...mockPlayerOne,
inventory: {
ruby: 2,
sapphire: 2,
emerald: 2,
diamond: 2,
onyx: 2,
gold: 2
}
}
expect(hasMaxChips(illegalPlayer)).toBeTruthy();
})
describe('validateChips', () => {
test('is falsy when chips action is not active', () => {
expect(validateChips(mockState)).toBeFalsy();
})
test('is falsy when more than three chips selected', () => {
const illegalState = getChipsState;
illegalState.actions.getChips.selection = ['ruby', 'diamond', 'onyx', 'sapphire']
expect(validateChips(illegalState)).toBeFalsy();
})
test('proper handling of duplicates', () => {
const illegalState = getChipsState;
illegalState.actions.getChips.selection = ['ruby', 'ruby', 'ruby']
const legalState = getChipsState;
legalState.actions.getChips.selection = ['ruby', 'ruby']
expect(validateChips(illegalState)).toBeFalsy();
expect(validateChips(legalState)).toBeTruthy();
})
test('no pickup of unavailable resources', () => {
const illegalState = {
...mockState,
gameboard: {
...getChipsState.gameboard,
tradingResources: {
ruby: 4,
sapphire: 4,
emerald: 1,
diamond: 4,
onyx: 2,
gold: 4
}
},
actions: {
...initialActions,
}
}
})
})
describe('getChips', () => {
})
})