Files
2026-10-08 12:32:33 +02:00

26 lines
1019 B
TypeScript

import { describe, it, expect } from 'vitest';
import { createNewGame, DAY_START_MINUTES, setPrice, SHELF_SLOT_COUNT } from '../../src/sim/state';
import { START_DATE } from '../../src/sim/calendar';
import { STARTING_CASH_CENTS } from '../../src/sim/economy';
describe('state', () => {
it('creates a new game on 28/09/1990 at 8:00', () => {
const s = createNewGame(123);
expect(s.saveVersion).toBe(1);
expect(s.date).toEqual(START_DATE);
expect(s.minutes).toBe(DAY_START_MINUTES);
expect(s.cash).toBe(STARTING_CASH_CENTS);
expect(s.reputation).toBe(20);
expect(s.inventory.slots).toHaveLength(SHELF_SLOT_COUNT);
expect(s.rngState).toBe(123);
expect(s.bankrupt).toBe(false);
});
it('sets a positive price', () => {
const s = createNewGame(1);
setPrice(s, { gameId: 'tetris', condition: 'new' }, 2500);
expect(s.prices['tetris|new']).toBe(2500);
expect(() => setPrice(s, { gameId: 'tetris', condition: 'new' }, 0)).toThrow('Price must be positive');
});
});