// Minimal unit test for 1a2b mini-game scoring flow (first-guess immediate win) // This is a skeleton to illustrate how to validate the first-guess high score path. // The actual test-runner and Vue test-utils setup may vary in your repo. import Vue from 'vue' import { mount, createLocalVue } from '@vue/test-utils' import Game1a2b from '../../../cfc-frontend/pages/games/1a2b.vue' // Mock API module jest.mock('../../../cfc-frontend/utils/api.js', () => ({ completeMiniGame: jest.fn(() => Promise.resolve({ code: 200, data: { pointsEarned: 10, newBalance: 110 } })), getChildren: jest.fn(() => Promise.resolve({ data: [{ id: 'child1' }] })) })) describe('1a2b.vue - first-guess immediate win', () => { const localVue = createLocalVue() it('awards 100 points on immediate win and submits score', async () => { const wrapper = mount(Game1a2b, { localVue, mocks: { $t: () => {} // if i18n is used } }) // Force deterministic answer by overriding generateAnswer wrapper.vm.generateAnswer = () => '1234' // Prepare child id await wrapper.vm.loadChildId() // Set user guess equal to answer to trigger immediate win on start wrapper.setData({ userGuess: '1234' }) // Start the game await wrapper.vm.startGame() // Assertions for first-guess instant win expect(wrapper.vm.gameOver).toBe(true) expect(wrapper.vm.isWin).toBe(true) expect(wrapper.vm.score).toBe(100) // Ensure submitScore was invoked (mocked API should be called) const api = require('../../../cfc-frontend/utils/api.js') expect(api.completeMiniGame).toHaveBeenCalled() }) })