diff --git a/public/images/scoreboard.avif b/public/images/scoreboard.avif new file mode 100644 index 0000000..c0f2f84 Binary files /dev/null and b/public/images/scoreboard.avif differ diff --git a/src/components/Scoreboard/Scoreboard.vue b/src/components/Scoreboard/Scoreboard.vue new file mode 100644 index 0000000..f58612c --- /dev/null +++ b/src/components/Scoreboard/Scoreboard.vue @@ -0,0 +1,82 @@ + + + diff --git a/tests/unit/Scoreboard/Scoreboard.spec.js b/tests/unit/Scoreboard/Scoreboard.spec.js new file mode 100644 index 0000000..5a07311 --- /dev/null +++ b/tests/unit/Scoreboard/Scoreboard.spec.js @@ -0,0 +1,87 @@ +import { mount } from '@vue/test-utils' + +import { createTestingPinia } from '@pinia/testing' + +import Scoreboard from '@/components/Scoreboard/Scoreboard.vue' + +describe('Scoreboard Empty', () => { + let wrapper + + beforeEach(() => { + wrapper = mount(Scoreboard, { + props: { + question: 'Which player answered correctly?' + }, + global: { + plugins: [createTestingPinia()] + } + }) + }) + + it('renders with no players', async () => { + expect(wrapper.vm.game.players.length).toBe(0) + }) +}) + +describe('Scoreboard', () => { + let wrapper + + beforeEach(() => { + wrapper = mount(Scoreboard, { + props: { + question: 'Which player answered correctly?' + }, + global: { + plugins: [createTestingPinia({ + stubActions: false, + initialState: { + 'hack.party game board': { + game: { + players: [ + { + index: 0, + name: 'Morty', + score: 0, + team: undefined + }, + { + index: 1, + name: 'noob noob', + score: 0, + team: undefined + }, + { + index: 2, + name: 'Rick', + score: 0, + team: undefined + } + ] + } + } + } + })] + } + }) + }) + + it('renders with players', async () => { + expect(wrapper.vm.game.players.length).toBe(3) + }) + + it('awards a point to the first player', async () => { + const button = await wrapper.find('button') + await button.trigger('click') + + debugger + + expect(wrapper.vm.game.players[0].score).toBe(1) + }) + + it('awards a point to the third player', async () => { + const buttons = await wrapper.findAll('button') + await buttons[2].trigger('click') + + expect(wrapper.vm.game.players[2].score).toBe(1) + }) +})