diff --git a/src/components/UpdateNotifier/UpdateNotifier.js b/src/components/UpdateNotifier/UpdateNotifier.js index 3dcc989c..639f0465 100644 --- a/src/components/UpdateNotifier/UpdateNotifier.js +++ b/src/components/UpdateNotifier/UpdateNotifier.js @@ -1,4 +1,4 @@ -import React, { useContext, useEffect } from 'react' +import { useContext, useEffect } from 'react' import { useRegisterSW } from 'virtual:pwa-register/react' import FarmhandContext from '../Farmhand/Farmhand.context' @@ -20,13 +20,13 @@ const UpdateNotifier = () => { handleGameUpdateAvailable(updateServiceWorker) - // NOTE: Ensure the game is updated when the user opens the game next. + // NOTE: This ensures the game is updated when the user next opensit. window.addEventListener('beforeunload', () => { updateServiceWorker(true) }) }, [appNeedsUpdate, handleGameUpdateAvailable, updateServiceWorker]) - return <> + return null } export default UpdateNotifier diff --git a/src/game-logic/reducers/sellItem.test.js b/src/game-logic/reducers/sellItem.test.js index 64994efa..38cbf6a1 100644 --- a/src/game-logic/reducers/sellItem.test.js +++ b/src/game-logic/reducers/sellItem.test.js @@ -141,7 +141,7 @@ describe('sellItem', () => { todaysNotifications: [], revenue: 0, todaysRevenue: 0, - valueAdjustments: { [carrotSeed.id]: 10 }, + valueAdjustments: { [carrotSeed.id]: 1 }, }, testItem({ id: carrotSeed.id }), 3 @@ -173,16 +173,16 @@ describe('sellItem', () => { todaysNotifications: [], revenue: 0, todaysRevenue: 0, - valueAdjustments: { [carrot.id]: 10 }, + valueAdjustments: { [carrot.id]: 1 }, }, testItem({ id: carrot.id }), 3 ) - expect(state.loanBalance).toEqual(62.5) - expect(state.money).toEqual(812.5) - expect(state.revenue).toEqual(712.5) - expect(state.todaysRevenue).toEqual(712.5) + expect(state.loanBalance).toEqual(96.25) + expect(state.money).toEqual(171.25) + expect(state.revenue).toEqual(71.25) + expect(state.todaysRevenue).toEqual(71.25) }) }) @@ -199,7 +199,7 @@ describe('sellItem', () => { todaysNotifications: [], revenue: 0, todaysRevenue: 0, - valueAdjustments: { [carrot.id]: 10 }, + valueAdjustments: { [carrot.id]: 1 }, }, testItem({ id: carrot.id }), 3 @@ -211,8 +211,8 @@ describe('sellItem', () => { }) test('sale is reduced based on remaining loan balance', () => { - expect(state.money).toEqual(848.5) - expect(state.todaysRevenue).toEqual(748.5) + expect(state.money).toEqual(173.5) + expect(state.todaysRevenue).toEqual(73.5) }) test('payoff notification is shown', () => { diff --git a/src/img/index.js b/src/img/index.js index 85f3129e..c0e00579 100644 --- a/src/img/index.js +++ b/src/img/index.js @@ -191,6 +191,8 @@ import goldIngot from './ores/gold-ingot.png' // Cows import rainbowCow from './animals/cows/rainbow-cow.png' +// NOTE: These need to be imported as dataUri strings because the image data is +// programmatically manipulated by the getCowImage utility function. import cowVariation1 from './animals/cows/cow-variation-1.png?dataUri' import cowVariation2 from './animals/cows/cow-variation-2.png?dataUri' import cowVariation3 from './animals/cows/cow-variation-3.png?dataUri' diff --git a/src/shell/field.test.js b/src/shell/field.test.js index 75bc33a6..f729f8c6 100644 --- a/src/shell/field.test.js +++ b/src/shell/field.test.js @@ -72,10 +72,10 @@ describe('field interaction', () => { test('can enable fertilize mode', async () => { const field = screen.getByTestId('field') - const [, carrotSeedButton] = screen.getAllByAltText(fertilizer.name) + const [, fertilizerButton] = screen.getAllByAltText(fertilizer.name) expect(field).not.toHaveClass('fertilize-mode') - userEvent.click(carrotSeedButton) + userEvent.click(fertilizerButton) expect(field).toHaveClass('fertilize-mode') }) }) diff --git a/vite.config.js b/vite.config.js index 5b643083..1f02a922 100644 --- a/vite.config.js +++ b/vite.config.js @@ -10,7 +10,7 @@ import { manifest } from './manifest' // NOTE: See: // - https://stackoverflow.com/a/78012267/470685 // - https://www.codu.co/articles/converting-an-image-to-a-data-uri-string-in-node-js-dznt83ha -const base64Loader = { +const dataUriLoader = { name: 'dataUri-loader', transform(_, id) { const [path, query] = id.split('?') @@ -63,7 +63,7 @@ const viteConfig = defineConfig({ }) }, }, - base64Loader, + dataUriLoader, ], resolve: { alias: [ @@ -78,15 +78,6 @@ const viteConfig = defineConfig({ // NOTE: By default, Vite doesn't include shims for NodeJS. global: {}, }, - // NOTE: This makes Vite treat .js files as .jsx (for legacy support) - // See: https://stackoverflow.com/a/76458411/470685 - optimizeDeps: { - esbuildOptions: { - loader: { - '.js': 'jsx', - }, - }, - }, }) const vitestConfig = vitestDefineConfig({