@jeremyckahn/farmhand
Version:
A farming game
37 lines (29 loc) • 1.06 kB
JavaScript
import { testCrop, testState } from '../../test-utils/index.js'
import { getPlotContentFromItemId } from '../../utils/index.js'
import { processSprinklers } from './processSprinklers.js'
vitest.mock('../../data/items.js')
describe('processSprinklers', () => {
let computedState
beforeEach(() => {
const field = new Array(8).fill(null).map(() => new Array(8).fill(null))
field[0][0] = getPlotContentFromItemId('sprinkler')
field[1][1] = getPlotContentFromItemId('sprinkler')
field[6][5] = getPlotContentFromItemId('sprinkler')
field[1][0] = testCrop()
field[2][2] = testCrop()
field[3][3] = testCrop()
computedState = processSprinklers(
testState({
field,
itemsSold: {},
})
)
})
test('waters crops within range', () => {
expect(computedState.field[1][0].wasWateredToday).toBeTruthy()
expect(computedState.field[2][2].wasWateredToday).toBeTruthy()
})
test('does not water crops out of range', () => {
expect(computedState.field[3][3].wasWateredToday).toBeFalsy()
})
})