-
{{ leaderboard.categories[0] ?? 'TODO' }}
+
{{
+ leaderboard.categories[0]?.name ?? 'TODO'
+ }}
YEAR
', () => {
+describe('
', () => {
function getLeaderboardInfoWrapper() {
return mount(LeaderboardInfo, {
props: {
@@ -35,6 +36,7 @@ describe.skip('
', () => {
afterEach(() => {
vi.restoreAllMocks()
+ vi.unstubAllGlobals()
})
enableAutoUnmount(afterEach)
@@ -44,13 +46,22 @@ describe.skip('
', () => {
expect(wrapper.isVisible()).toBe(true)
})
- it('should trigger follow button', async () => {
+ it('should render
if device width is large', () => {
+ vi.stubGlobal('innerWidth', 1980)
const wrapper = getLeaderboardInfoWrapper()
- await getByTestId(wrapper, 'middle__follow').trigger('click')
- expect(wrapper.emitted().follow?.[0]).toEqual([1])
+ expect(wrapper.html()).toContain('Guides')
})
- it('should trigger', () => {
- //
+ it('should render
if device width is small', () => {
+ vi.stubGlobal('innerWidth', 600)
+ const wrapper = getLeaderboardInfoWrapper()
+ expect(wrapper.html()).toContain('Submit Run')
+ })
+
+ // TODO: The follow event doesn't trigger in the test, somehow
+ it.skip('should emit event when the Follow Button is triggered', async () => {
+ const wrapper = getLeaderboardInfoWrapper()
+ await getByTestId(wrapper, 'child').trigger('follow')
+ expect(wrapper.emitted().follow).toBeTruthy()
})
})
diff --git a/components/blocks/LeaderboardInfo/Mobile/Mobile.test.ts b/components/blocks/LeaderboardInfo/Mobile/Mobile.test.ts
new file mode 100644
index 00000000..045248ff
--- /dev/null
+++ b/components/blocks/LeaderboardInfo/Mobile/Mobile.test.ts
@@ -0,0 +1,36 @@
+import { enableAutoUnmount, mount } from '@vue/test-utils'
+import { vi } from 'vitest'
+import { getByTestId } from 'root/testUtils'
+import Mobile from './Mobile.vue'
+
+describe('
', () => {
+ function getMobileWrapper() {
+ return mount(Mobile, {
+ props: {
+ leaderboard: {
+ categories: [{ id: 1, name: 'Any%', slug: 'any' }],
+ id: 1,
+ name: 'Stuck in the Train Simulator 2',
+ slug: 'stuck-in-the-train-sim-2',
+ },
+ todoPlatforms: ['XBox', 'PC'],
+ },
+ })
+ }
+
+ afterEach(() => {
+ vi.restoreAllMocks()
+ })
+
+ enableAutoUnmount(afterEach)
+
+ it('should render without crashing', () => {
+ const wrapper = getMobileWrapper()
+ expect(wrapper.isVisible()).toBe(true)
+
+ expect(getByTestId(wrapper, 'title').text()).toBe(
+ 'Stuck in the Train Simulator 2',
+ )
+ expect(getByTestId(wrapper, 'tag').text()).toBe('Any%')
+ })
+})
diff --git a/components/blocks/LeaderboardInfo/Mobile/Mobile.vue b/components/blocks/LeaderboardInfo/Mobile/Mobile.vue
index 311419ef..99c16642 100644
--- a/components/blocks/LeaderboardInfo/Mobile/Mobile.vue
+++ b/components/blocks/LeaderboardInfo/Mobile/Mobile.vue
@@ -20,7 +20,9 @@ defineProps
()
-
{{ leaderboard.name || 'Game Name' }}
+
+ {{ leaderboard.name || 'Game Name' }}
+
()
- {{ leaderboard.categories[0] ?? 'TODO' }}
+ {{
+ leaderboard.categories[0]?.name ?? 'TODO'
+ }}
YEAR
diff --git a/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.test.ts b/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.test.ts
index c0f2a13a..2ff7c8f8 100644
--- a/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.test.ts
+++ b/components/blocks/LeaderboardInfo/PlatformTags/PlatformTags.test.ts
@@ -2,13 +2,22 @@ import { mount } from '@vue/test-utils'
import PlatformTags from './PlatformTags.vue'
describe('
', () => {
+ const tags = ['XBox', 'PS4', 'Amiga DS']
+
it('should render without crashing', () => {
const wrapper = mount(PlatformTags, {
props: {
- tags: ['XBox', 'PS4', 'Amiga DS'],
+ tags,
},
})
expect(wrapper.isVisible()).toBe(true)
+
+ wrapper
+ .getComponent('div.platform-tags')
+ .findAllComponents('div')
+ .forEach((c, i) => {
+ expect(c.text()).toBe(tags[i])
+ })
})
})