diff --git a/components/blocks/Landing/LandingLeaderboards.test.ts b/components/blocks/Landing/LandingLeaderboards.test.ts index a74e0b38..ea7a0f56 100644 --- a/components/blocks/Landing/LandingLeaderboards.test.ts +++ b/components/blocks/Landing/LandingLeaderboards.test.ts @@ -7,7 +7,7 @@ const games: LeaderboardViewModel[] = [ id: 1, name: 'Getting Over It With Bennet Foddy', slug: 'slug-2', - info: null, + info: '', createdAt: '2024-11-02T22:11:08+0000', updatedAt: '2024-11-02T22:11:08+0000', deletedAt: null, @@ -17,7 +17,7 @@ const games: LeaderboardViewModel[] = [ id: 2, name: 'Getting Over It With Bennet Foddy', slug: 'slug-2', - info: null, + info: '', createdAt: '2024-11-02T22:11:08+0000', updatedAt: '2024-11-02T22:11:08+0000', deletedAt: null, @@ -27,7 +27,7 @@ const games: LeaderboardViewModel[] = [ id: 3, name: 'Getting Over It With Bennet Foddy', slug: 'slug-3', - info: null, + info: '', createdAt: '2024-11-02T22:11:08+0000', updatedAt: '2024-11-02T22:11:08+0000', deletedAt: null, diff --git a/components/blocks/LeaderboardInfo/LeaderboardInfo.test.ts b/components/blocks/LeaderboardInfo/LeaderboardInfo.test.ts new file mode 100644 index 00000000..bd4bf512 --- /dev/null +++ b/components/blocks/LeaderboardInfo/LeaderboardInfo.test.ts @@ -0,0 +1,30 @@ +import { mountSuspended } from '@nuxt/test-utils/runtime' +import LeaderboardInfo from './LeaderboardInfo.vue' +import type { LeaderboardViewModel } from '~/lib/api/data-contracts' + +const game: LeaderboardViewModel = { + id: 1, + name: 'Getting Over It With Bennet Foddy', + slug: 'slug-2', + info: 'Something special', + createdAt: '2024-11-02T22:11:08+0000', + updatedAt: '2024-11-02T22:11:08+0000', + deletedAt: null, + categories: [], +} + +describe('LeaderboardInfo Component', () => { + it('should render without crashing', async () => { + const wrapper = await mountSuspended(LeaderboardInfo, { + props: { + leaderboard: game, + }, + }) + + expect(wrapper.isVisible()).toBe(true) + + const header = wrapper.get('div#leaderboard-show-header h1') + + expect(header.text()).toContain(game.name) + }) +}) diff --git a/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.test.ts b/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.test.ts new file mode 100644 index 00000000..a36560d8 --- /dev/null +++ b/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.test.ts @@ -0,0 +1,25 @@ +import { mountSuspended } from '@nuxt/test-utils/runtime' +import LeaderboardInfoAccordion from './LeaderboardInfoAccordion.vue' + +const info = 'Some Special Info' + +describe('LeaderboardInfoAccordion Component', () => { + it('should render without crashing', async () => { + const wrapper = await mountSuspended(LeaderboardInfoAccordion, { + props: { + info: info, + }, + }) + + expect(wrapper.isVisible()).toBe(true) + + // click the info button to open the info pane + const button = wrapper.get('button#leaderboard-info-button') + button.trigger('click') + await wrapper.vm.$nextTick() + + const infoText = wrapper.get('p#leaderboard-info-text') + + expect(infoText.text()).toContain(info) + }) +}) diff --git a/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.vue b/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.vue index e8b0c4bf..aadf926e 100644 --- a/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.vue +++ b/components/blocks/LeaderboardInfo/LeaderboardInfoAccordion.vue @@ -1,5 +1,6 @@