Files
gold_land_user/test/gold-guess-rewards.test.ts
T
safavimohadeseh78andCursor e3f0457dc9
Frontend CI / unit (test, type-check, build) (push) Successful in 1m11s
Frontend CI / browser E2E (frontend + pinned backend) (push) Failing after 2m48s
feat: complete server-backed six-lesson app and trial tooling
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-12 14:40:37 +03:30

50 lines
1.5 KiB
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { createPinia, setActivePinia } from 'pinia'
import { installFetchMock, resetAppTestState } from './helpers/fetchMock'
test.beforeEach(async () => {
installFetchMock()
await resetAppTestState()
setActivePinia(createPinia())
})
test('games catalog exposes gold-guess rewards from GET /games', async () => {
globalThis.routeHandlers!.set('/games', () => ({
status: 200,
body: [
{
id: 'gold-guess',
title: 'حدس',
description: 'd',
icon: '📈',
color: '#7438c9',
route: '/games/gold-guess',
rewardCoins: 20,
rewardXp: 50,
},
],
}))
const { useGamesStore } = await import('../src/stores/games')
const games = useGamesStore()
await games.loadCatalog()
const item = games.gameById('gold-guess')
assert.ok(item)
assert.equal(item!.rewardCoins, 20)
assert.equal(item!.rewardXp, 50)
})
test('unknown game id returns null without throwing', async () => {
globalThis.routeHandlers!.set('/games', () => ({ status: 200, body: [] }))
const { useGamesStore } = await import('../src/stores/games')
const games = useGamesStore()
await games.loadCatalog()
assert.equal(games.gameById('missing-game'), null)
})
declare global {
// eslint-disable-next-line no-var
var routeHandlers: Map<string, (init?: RequestInit) => import('./helpers/fetchMock').MockResponse | Promise<import('./helpers/fetchMock').MockResponse>>
}