From 3da777dbb22ae65c66ae6393811ce3771644d8aa Mon Sep 17 00:00:00 2001 From: Phan An Date: Sun, 16 Jun 2024 17:40:33 +0200 Subject: [PATCH] fix: sidebar toggling on mobile (fr) --- .../main-wrapper/sidebar/HomeButton.spec.ts | 17 +++++++++++++++++ .../main-wrapper/sidebar/HomeButton.vue | 16 ++++++++++++++++ .../layout/main-wrapper/sidebar/Sidebar.vue | 19 +++---------------- .../main-wrapper/sidebar/SidebarItem.spec.ts | 13 +++++++++++-- .../main-wrapper/sidebar/SidebarItem.vue | 4 ++++ .../components/podcast/PodcastListSorter.vue | 4 ++-- .../components/ui/SidebarMenuToggleButton.vue | 12 ++++-------- 7 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 resources/assets/js/components/layout/main-wrapper/sidebar/HomeButton.spec.ts create mode 100644 resources/assets/js/components/layout/main-wrapper/sidebar/HomeButton.vue diff --git a/resources/assets/js/components/layout/main-wrapper/sidebar/HomeButton.spec.ts b/resources/assets/js/components/layout/main-wrapper/sidebar/HomeButton.spec.ts new file mode 100644 index 00000000..b776efa6 --- /dev/null +++ b/resources/assets/js/components/layout/main-wrapper/sidebar/HomeButton.spec.ts @@ -0,0 +1,17 @@ +import { screen } from '@testing-library/vue' +import { expect, it } from 'vitest' +import UnitTestCase from '@/__tests__/UnitTestCase' +import { eventBus } from '@/utils' +import Component from './HomeButton.vue' + +new class extends UnitTestCase { + protected test () { + it('triggers the sidebar toggle event', async () => { + this.mock(eventBus, 'emit') + this.render(Component) + await this.user.click(screen.getByRole('link')) + + expect(eventBus.emit).toHaveBeenCalledWith('TOGGLE_SIDEBAR') + }) + } +} diff --git a/resources/assets/js/components/layout/main-wrapper/sidebar/HomeButton.vue b/resources/assets/js/components/layout/main-wrapper/sidebar/HomeButton.vue new file mode 100644 index 00000000..f7a9ee7f --- /dev/null +++ b/resources/assets/js/components/layout/main-wrapper/sidebar/HomeButton.vue @@ -0,0 +1,16 @@ + + + diff --git a/resources/assets/js/components/layout/main-wrapper/sidebar/Sidebar.vue b/resources/assets/js/components/layout/main-wrapper/sidebar/Sidebar.vue index ddeea260..91a5e5f6 100644 --- a/resources/assets/js/components/layout/main-wrapper/sidebar/Sidebar.vue +++ b/resources/assets/js/components/layout/main-wrapper/sidebar/Sidebar.vue @@ -1,18 +1,12 @@