diff --git a/resources/assets/js/components/song/song-list/SongListHeader.spec.ts b/resources/assets/js/components/song/song-list/SongListHeader.spec.ts index 6b3e2afd..3bc81216 100644 --- a/resources/assets/js/components/song/song-list/SongListHeader.spec.ts +++ b/resources/assets/js/components/song/song-list/SongListHeader.spec.ts @@ -70,7 +70,7 @@ new class extends UnitTestCase { }, global: { stubs: { - SongListSorter: this.stub('song-list-sorter'), + ActionMenu: this.stub('song-list-header-action-menu'), }, provide: { [SelectedPlayablesKey]: [ref(selectedPlayables), (value: Playable[]) => (selectedPlayables = value)], diff --git a/resources/assets/js/components/song/song-list/SongListHeader.vue b/resources/assets/js/components/song/song-list/SongListHeader.vue index 51654b43..74e9c120 100644 --- a/resources/assets/js/components/song/song-list/SongListHeader.vue +++ b/resources/assets/js/components/song/song-list/SongListHeader.vue @@ -66,8 +66,8 @@ - + contentType?: ReturnType }>(), { contentType: 'songs', }) diff --git a/resources/assets/js/components/song/song-list/SongListSorter.spec.ts b/resources/assets/js/components/song/song-list/SongListHeaderActionMenu.spec.ts similarity index 82% rename from resources/assets/js/components/song/song-list/SongListSorter.spec.ts rename to resources/assets/js/components/song/song-list/SongListHeaderActionMenu.spec.ts index da9c0cc9..be3596fd 100644 --- a/resources/assets/js/components/song/song-list/SongListSorter.spec.ts +++ b/resources/assets/js/components/song/song-list/SongListHeaderActionMenu.spec.ts @@ -2,7 +2,7 @@ import { screen } from '@testing-library/vue' import { expect, it } from 'vitest' import UnitTestCase from '@/__tests__/UnitTestCase' import { useLocalStorage } from '@/composables/useLocalStorage' -import Component from './SongListSorter.vue' +import Component from './SongListHeaderActionMenu.vue' new class extends UnitTestCase { protected test () { @@ -15,6 +15,12 @@ new class extends UnitTestCase { ) }) + it ('emits the sort event when an item is clicked', async () => { + const { emitted } = this.render(Component) + await this.user.click(screen.getByText('Title')) + expect(emitted().sort[0]).toEqual(['title']) + }) + it('contains proper items for episode-only lists', () => { this.render(Component, { props: { @@ -49,6 +55,17 @@ new class extends UnitTestCase { screen.getByText('Custom Order') }) + it('does not sort if the list is not sortable', async () => { + const { emitted } = this.render(Component, { + props: { + sortable: false, + }, + }) + + await this.user.click(screen.getByText('Title')) + expect(emitted().sort).toBeUndefined() + }) + it('has a checkbox to toggle the column visibility', async () => { this.be().render(Component) diff --git a/resources/assets/js/components/song/song-list/SongListSorter.vue b/resources/assets/js/components/song/song-list/SongListHeaderActionMenu.vue similarity index 94% rename from resources/assets/js/components/song/song-list/SongListSorter.vue rename to resources/assets/js/components/song/song-list/SongListHeaderActionMenu.vue index ac03ea6e..1484d8d0 100644 --- a/resources/assets/js/components/song/song-list/SongListSorter.vue +++ b/resources/assets/js/components/song/song-list/SongListHeaderActionMenu.vue @@ -1,7 +1,8 @@