@jeremyckahn/farmhand
Version:
A farming game
56 lines (48 loc) • 1.46 kB
JavaScript
import { COW_HUG_BENEFIT } from '../../constants.js'
import { generateCow } from '../../utils/index.js'
import { testState } from '../../test-utils/index.js'
import { hugCow } from './hugCow.js'
describe('hugCow', () => {
describe('cow has not hit daily hug benefit limit', () => {
test('increases cow happiness', () => {
const cow = generateCow()
const {
cowInventory: [{ happiness, happinessBoostsToday }],
} = hugCow(
testState({
cowInventory: [cow],
}),
cow.id
)
expect(happiness).toBe(COW_HUG_BENEFIT)
expect(happinessBoostsToday).toBe(1)
})
describe('cow is at max happiness', () => {
test('does not increase cow happiness', () => {
const cow = generateCow({ happiness: 1 })
const { cowInventory } = hugCow(
testState({
cowInventory: [cow],
}),
cow.id
)
expect(cowInventory[0].happiness).toBe(1)
})
})
})
describe('cow has hit daily hug benefit limit', () => {
test('does not increase cow happiness', () => {
const cow = generateCow({ happiness: 0.5, happinessBoostsToday: 3 })
const {
cowInventory: [{ happiness, happinessBoostsToday }],
} = hugCow(
testState({
cowInventory: [cow],
}),
cow.id
)
expect(happiness).toBe(0.5)
expect(happinessBoostsToday).toBe(3)
})
})
})