From b94c3de3b66c5f84e75aaad1f328930605454458 Mon Sep 17 00:00:00 2001 From: Phan An Date: Wed, 4 May 2022 23:01:35 +0200 Subject: [PATCH] test: add artist info unit tests --- .eslintrc | 6 ++- .../__tests__/components/artist/card.spec.ts | 53 ------------------- .../assets/js/components/album/AlbumCard.vue | 8 +-- .../js/components/album/AlbumInfo.spec.ts | 25 +++------ .../assets/js/components/album/AlbumInfo.vue | 12 ++--- .../js/components/artist/ArtistInfo.spec.ts | 42 +++++++++++++++ .../js/components/artist/ArtistInfo.vue | 12 +++-- .../js/components/ui/AlbumArtistThumbnail.vue | 2 +- 8 files changed, 72 insertions(+), 88 deletions(-) delete mode 100644 resources/assets/js/__tests__/components/artist/card.spec.ts create mode 100644 resources/assets/js/components/artist/ArtistInfo.spec.ts diff --git a/.eslintrc b/.eslintrc index b77978ae..7a09041a 100644 --- a/.eslintrc +++ b/.eslintrc @@ -41,9 +41,11 @@ "@typescript-eslint/no-non-null-assertion": 0, "@typescript-eslint/ban-ts-comment": 0, "@typescript-eslint/no-empty-function": 0, - "vue/no-side-effects-in-computed-properties": 0, "@typescript-eslint/explicit-module-boundary-types": 0, "standard/no-callback-literal": 0, - "vue/valid-v-on": 0 + "vue/valid-v-on": 0, + "vue/no-side-effects-in-computed-properties": 0, + "vue/max-attributes-per-line": 0, + "vue/no-v-html": 0 } } diff --git a/resources/assets/js/__tests__/components/artist/card.spec.ts b/resources/assets/js/__tests__/components/artist/card.spec.ts deleted file mode 100644 index ddcd2ea0..00000000 --- a/resources/assets/js/__tests__/components/artist/card.spec.ts +++ /dev/null @@ -1,53 +0,0 @@ -import Component from '@/components/artist/ArtistCard.vue' -import Thumbnail from '@/components/ui/AlbumArtistThumbnail.vue' -import factory from '@/__tests__/factory' -import { playbackService, downloadService } from '@/services' -import { commonStore } from '@/stores' -import { mock } from '@/__tests__/__helpers__' -import { mount, shallow } from '@/__tests__/adapter' - -describe('components/artist/card', () => { - let artist: Artist - - beforeEach(() => { - // @ts-ignore - commonStore.state = { allowDownload: true } - artist = factory('artist', { - id: 3, // make sure it's not "Various Artists" - albums: factory('album', 4), - songs: factory('song', 16) - }) - }) - - afterEach(() => { - jest.resetModules() - jest.clearAllMocks() - }) - - it('renders properly', async () => { - const wrapper = mount(Component, { propsData: { artist } }) - - await wrapper.vm.$nextTick() - expect(wrapper.has(Thumbnail)).toBe(true) - const html = wrapper.html() - expect(html).toMatch('4 albums') - expect(html).toMatch('16 songs') - expect(html).toMatch(artist.name) - }) - - it('shuffles', () => { - const wrapper = shallow(Component, { propsData: { artist } }) - const playStub = mock(playbackService, 'playAllByArtist') - - wrapper.click('.shuffle-artist') - expect(playStub).toHaveBeenCalledWith(artist, true) - }) - - it('downloads', () => { - const wrapper = shallow(Component, { propsData: { artist } }) - const downloadStub = mock(downloadService, 'fromArtist') - - wrapper.click('.download-artist') - expect(downloadStub).toHaveBeenCalledWith(artist) - }) -}) diff --git a/resources/assets/js/components/album/AlbumCard.vue b/resources/assets/js/components/album/AlbumCard.vue index ae49881b..3e33cc8f 100644 --- a/resources/assets/js/components/album/AlbumCard.vue +++ b/resources/assets/js/components/album/AlbumCard.vue @@ -12,7 +12,7 @@ @contextmenu.prevent="requestContextMenu" > - +