Skip to content

Commit 1c83111

Browse files
committed
Update title when track is playing.
1 parent 05eef7f commit 1c83111

37 files changed

Lines changed: 681 additions & 218 deletions

components/Molecules/PreloadImage.spec.ts

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ describe('Default', () => {
6464
);
6565
});
6666

67-
describe('when the lazyLoad prop is not set', () => {
68-
describe('when the image prop is set to a none IMAGE_DEFAULT_BY_TYPE icon', () => {
67+
describe('when the image prop is set to a none IMAGE_DEFAULT_BY_TYPE icon', () => {
68+
describe('when the lazyLoad prop is not set', () => {
6969
beforeEach(() => {
7070
wrapper = factory({
7171
image: 'image',
@@ -176,31 +176,31 @@ describe('Default', () => {
176176
});
177177
});
178178
});
179-
});
180179

181-
describe('when the lazyLoad prop is set to false', () => {
182-
beforeEach(() => {
183-
wrapper = factory({
184-
image: 'image',
185-
lazyLoad: false,
180+
describe('when the lazyLoad prop is set to false', () => {
181+
beforeEach(() => {
182+
wrapper = factory({
183+
image: 'image',
184+
lazyLoad: false,
185+
});
186186
});
187-
});
188-
189-
it('matches the snapshot', () => {
190-
expect(wrapper.html()).toMatchSnapshot();
191-
});
192187

193-
it('does not add the IntersectionObserver function', () => {
194-
expect(iOMock.observeMock).not.toHaveBeenCalled();
195-
});
188+
it('matches the snapshot', () => {
189+
expect(wrapper.html()).toMatchSnapshot();
190+
});
196191

197-
describe('when the component unmounts', () => {
198-
beforeEach(() => {
199-
wrapper.unmount();
192+
it('does not add the IntersectionObserver function', () => {
193+
expect(iOMock.observeMock).not.toHaveBeenCalled();
200194
});
201195

202-
it('does not call the IntersectionObserver disconnect function', () => {
203-
expect(iOMock.disconnectMock).not.toHaveBeenCalled();
196+
describe('when the component unmounts', () => {
197+
beforeEach(() => {
198+
wrapper.unmount();
199+
});
200+
201+
it('does not call the IntersectionObserver disconnect function', () => {
202+
expect(iOMock.disconnectMock).not.toHaveBeenCalled();
203+
});
204204
});
205205
});
206206
});

components/Molecules/PreloadImage.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ const imageSrc = computed(() => {
3030
return null;
3131
}
3232
33-
if (isUrl(props.image)) {
34-
return props.image;
35-
}
36-
3733
return getImageUrl(props.image);
3834
});
3935

components/Molecules/__snapshots__/PreloadImage.spec.ts.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
22

3+
exports[`Default > when the image prop is set to a none IMAGE_DEFAULT_BY_TYPE icon > when the lazyLoad prop is not set > matches the snapshot 1`] = `"<div class="centerAll preloadImage"><span class="skeletonLoader"><span class="visuallyHidden">Loading image</span></span><img alt="Image" class="image" draggable="false" loading="lazy" src="image" style="display: none;"></div>"`;
4+
5+
exports[`Default > when the image prop is set to a none IMAGE_DEFAULT_BY_TYPE icon > when the lazyLoad prop is not set > when intersectionObserver is intersecting > when image has finished loading > matches the snapshot 1`] = `"<div class="centerAll preloadImage"><span class="skeletonLoader" style="display: none;"><span class="visuallyHidden">Loading image</span></span><img alt="Image" class="image" draggable="false" loading="lazy" src="image"></div>"`;
6+
7+
exports[`Default > when the image prop is set to a none IMAGE_DEFAULT_BY_TYPE icon > when the lazyLoad prop is not set > when intersectionObserver is intersecting > when the alt prop is set > matches the snapshot 1`] = `"<div class="centerAll preloadImage"><span class="skeletonLoader"><span class="visuallyHidden">Loading image</span></span><img alt="Alt text for image" class="image" draggable="false" loading="lazy" src="https://test.com"></div>"`;
8+
9+
exports[`Default > when the image prop is set to a none IMAGE_DEFAULT_BY_TYPE icon > when the lazyLoad prop is set to false > matches the snapshot 1`] = `"<div class="centerAll preloadImage"><span class="skeletonLoader"><span class="visuallyHidden">Loading image</span></span><img alt="Image" class="image" draggable="false" loading="lazy" src="image" style="display: none;"></div>"`;
10+
311
exports[`Default > when the image prop is set to an IMAGE_DEFAULT_BY_TYPE icon > when the image prop is set to PhApplePodcastsLogo > matches the snapshot 1`] = `
412
"<div class="centerAll preloadImage">
513
<div class="iconImage">
@@ -95,11 +103,3 @@ exports[`Default > when the image prop is set to an IMAGE_DEFAULT_BY_TYPE icon >
95103
</div>
96104
</div>"
97105
`;
98-
99-
exports[`Default > when the lazyLoad prop is not set > when the image prop is set to a none IMAGE_DEFAULT_BY_TYPE icon > matches the snapshot 1`] = `"<div class="centerAll preloadImage"><span class="skeletonLoader"><span class="visuallyHidden">Loading image</span></span><img alt="Image" class="image" draggable="false" loading="lazy" src="image" style="display: none;"></div>"`;
100-
101-
exports[`Default > when the lazyLoad prop is not set > when the image prop is set to a none IMAGE_DEFAULT_BY_TYPE icon > when intersectionObserver is intersecting > when image has finished loading > matches the snapshot 1`] = `"<div class="centerAll preloadImage"><span class="skeletonLoader" style="display: none;"><span class="visuallyHidden">Loading image</span></span><img alt="Image" class="image" draggable="false" loading="lazy" src="image"></div>"`;
102-
103-
exports[`Default > when the lazyLoad prop is not set > when the image prop is set to a none IMAGE_DEFAULT_BY_TYPE icon > when intersectionObserver is intersecting > when the alt prop is set > matches the snapshot 1`] = `"<div class="centerAll preloadImage"><span class="skeletonLoader"><span class="visuallyHidden">Loading image</span></span><img alt="Alt text for image" class="image" draggable="false" loading="lazy" src="https://test.com"></div>"`;
104-
105-
exports[`Default > when the lazyLoad prop is set to false > matches the snapshot 1`] = `"<div class="centerAll preloadImage"><span class="skeletonLoader"><span class="visuallyHidden">Loading image</span></span><img alt="Image" class="image" draggable="false" loading="lazy" src="image" style="display: none;"></div>"`;

components/Organisms/FileListItem.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import type { VueWrapper } from '@vue/test-utils';
22

3-
import { mockNuxtImport } from '@nuxt/test-utils/runtime';
43
import { mount } from '@vue/test-utils';
54

65
import InteractionWrapper from '@/components/Atoms/InteractionWrapper.vue';
76
import TrackPlayPause from '@/components/Organisms/TrackPlayPause.vue';
87
import { getFormattedTracksMock } from '@/test/helpers';
8+
import { useAudioPlayerMock } from '@/test/useAudioPlayerMock';
99

1010
import FileListItem from './FileListItem.vue';
1111

12-
const isCurrentTrackMock = vi.fn().mockReturnValue(false);
13-
14-
mockNuxtImport('useAudioPlayer', () => () => ({
15-
isCurrentTrack: isCurrentTrackMock,
16-
}));
12+
const { isCurrentTrackMock } = useAudioPlayerMock();
1713

1814
const track = getFormattedTracksMock()[0];
1915

components/Organisms/TrackLists/AlbumTracksListItem.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import type { VueWrapper } from '@vue/test-utils';
22

3-
import { mockNuxtImport } from '@nuxt/test-utils/runtime';
43
import { mount } from '@vue/test-utils';
54

65
import InteractionWrapper from '@/components/Atoms/InteractionWrapper.vue';
76
import TrackPlayPause from '@/components/Organisms/TrackPlayPause.vue';
87
import { getFormattedTracksMock } from '@/test/helpers';
8+
import { useAudioPlayerMock } from '@/test/useAudioPlayerMock';
99

1010
import AlbumTracksListItem from './AlbumTracksListItem.vue';
1111

12-
const isCurrentTrackMock = vi.fn().mockReturnValue(false);
13-
14-
mockNuxtImport('useAudioPlayer', () => () => ({
15-
isCurrentTrack: isCurrentTrackMock,
16-
}));
12+
const { isCurrentTrackMock } = useAudioPlayerMock();
1713

1814
const track = getFormattedTracksMock()[0];
1915

components/Organisms/TrackLists/BookmarksTracksListItem.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import type { VueWrapper } from '@vue/test-utils';
22

3-
import { mockNuxtImport } from '@nuxt/test-utils/runtime';
43
import { mount } from '@vue/test-utils';
54

65
import InteractionWrapper from '@/components/Atoms/InteractionWrapper.vue';
76
import TrackPlayPause from '@/components/Organisms/TrackPlayPause.vue';
87
import { getFormattedBookmarksMock } from '@/test/helpers';
8+
import { useAudioPlayerMock } from '@/test/useAudioPlayerMock';
99

1010
import BookmarksTracksListItem from './BookmarksTracksListItem.vue';
1111

12-
const isCurrentTrackMock = vi.fn().mockReturnValue(false);
13-
14-
mockNuxtImport('useAudioPlayer', () => () => ({
15-
isCurrentTrack: isCurrentTrackMock,
16-
}));
12+
const { isCurrentTrackMock } = useAudioPlayerMock();
1713

1814
const bookmark = getFormattedBookmarksMock()[0];
1915

components/Organisms/TrackLists/MixedTracksListItem.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { VueWrapper } from '@vue/test-utils';
22

3-
import { mockNuxtImport } from '@nuxt/test-utils/runtime';
43
import { mount } from '@vue/test-utils';
54

65
import InteractionWrapper from '@/components/Atoms/InteractionWrapper.vue';
@@ -11,14 +10,11 @@ import {
1110
getFormattedRadioStationMock,
1211
getFormattedTracksMock,
1312
} from '@/test/helpers';
13+
import { useAudioPlayerMock } from '@/test/useAudioPlayerMock';
1414

1515
import MixedTracksListItem from './MixedTracksListItem.vue';
1616

17-
const isCurrentTrackMock = vi.fn().mockReturnValue(false);
18-
19-
mockNuxtImport('useAudioPlayer', () => () => ({
20-
isCurrentTrack: isCurrentTrackMock,
21-
}));
17+
const { isCurrentTrackMock } = useAudioPlayerMock();
2218

2319
const track = getFormattedTracksMock()[0];
2420

components/Organisms/TrackLists/PodcastEpisodesListItem.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import type { VueWrapper } from '@vue/test-utils';
22

3-
import { mockNuxtImport } from '@nuxt/test-utils/runtime';
43
import { mount } from '@vue/test-utils';
54

65
import InteractionWrapper from '@/components/Atoms/InteractionWrapper.vue';
76
import DownloadPodcastEpisode from '@/components/Organisms/DownloadPodcastEpisode.vue';
87
import TrackPlayPause from '@/components/Organisms/TrackPlayPause.vue';
98
import { getFormattedPodcastEpisodesMock } from '@/test/helpers';
9+
import { useAudioPlayerMock } from '@/test/useAudioPlayerMock';
1010

1111
import PodcastEpisodesListItem from './PodcastEpisodesListItem.vue';
1212

13-
const isCurrentTrackMock = vi.fn().mockReturnValue(false);
14-
15-
mockNuxtImport('useAudioPlayer', () => () => ({
16-
isCurrentTrack: isCurrentTrackMock,
17-
}));
13+
const { isCurrentTrackMock } = useAudioPlayerMock();
1814

1915
const downloadedEpisode = getFormattedPodcastEpisodesMock()[0];
2016
const noneDownloadedEpisode = getFormattedPodcastEpisodesMock(1, {

components/Organisms/TrackLists/RadioStationsListItem.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import type { VueWrapper } from '@vue/test-utils';
22

3-
import { mockNuxtImport } from '@nuxt/test-utils/runtime';
43
import { mount } from '@vue/test-utils';
54

65
import InteractionWrapper from '@/components/Atoms/InteractionWrapper.vue';
76
import TrackPlayPause from '@/components/Organisms/TrackPlayPause.vue';
87
import { getFormattedRadioStationMock } from '@/test/helpers';
8+
import { useAudioPlayerMock } from '@/test/useAudioPlayerMock';
99

1010
import RadioStationsListItem from './RadioStationsListItem.vue';
1111

12-
const isCurrentTrackMock = vi.fn().mockReturnValue(false);
13-
14-
mockNuxtImport('useAudioPlayer', () => () => ({
15-
isCurrentTrack: isCurrentTrackMock,
16-
}));
12+
const { isCurrentTrackMock } = useAudioPlayerMock();
1713

1814
const radioStation = getFormattedRadioStationMock()[0];
1915

components/Organisms/TrackLists/TracksListItem.spec.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
import type { VueWrapper } from '@vue/test-utils';
22

3-
import { mockNuxtImport } from '@nuxt/test-utils/runtime';
43
import { mount } from '@vue/test-utils';
54

65
import InteractionWrapper from '@/components/Atoms/InteractionWrapper.vue';
76
import TrackPlayPause from '@/components/Organisms/TrackPlayPause.vue';
87
import { getFormattedTracksMock } from '@/test/helpers';
8+
import { useAudioPlayerMock } from '@/test/useAudioPlayerMock';
99

1010
import TracksListItem from './TracksListItem.vue';
1111

12-
const isCurrentTrackMock = vi.fn().mockReturnValue(false);
13-
14-
mockNuxtImport('useAudioPlayer', () => () => ({
15-
isCurrentTrack: isCurrentTrackMock,
16-
}));
12+
const { isCurrentTrackMock } = useAudioPlayerMock();
1713

1814
const track = getFormattedTracksMock()[0];
1915

0 commit comments

Comments
 (0)