Format code with Prettier (8 modified files from H1 decomposition)
Aligns with CC2 enforcement: ESLint + Prettier + noImplicitAny now enforced. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
// Import from the pure utility module directly — no Zustand store init needed (L40).
|
||||
import { looksLikeUrl, looksLikeSingleVideo, youtubeId } from '../src/renderer/src/lib/urlHelpers'
|
||||
import {
|
||||
looksLikeUrl,
|
||||
looksLikeSingleVideo,
|
||||
looksLikeChannelOrPlaylist,
|
||||
youtubeId
|
||||
} from '../src/renderer/src/lib/urlHelpers'
|
||||
|
||||
describe('youtubeId', () => {
|
||||
it('extracts the id from a watch URL', () => {
|
||||
@@ -103,3 +108,37 @@ describe('looksLikeSingleVideo', () => {
|
||||
expect(looksLikeSingleVideo('')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('looksLikeChannelOrPlaylist', () => {
|
||||
it('flags YouTube channel URLs', () => {
|
||||
expect(looksLikeChannelOrPlaylist('https://www.youtube.com/@SomeChannel')).toBe(true)
|
||||
expect(looksLikeChannelOrPlaylist('https://www.youtube.com/@SomeChannel/videos')).toBe(true)
|
||||
expect(looksLikeChannelOrPlaylist('https://www.youtube.com/channel/UC123')).toBe(true)
|
||||
expect(looksLikeChannelOrPlaylist('https://www.youtube.com/c/SomeChannel')).toBe(true)
|
||||
expect(looksLikeChannelOrPlaylist('https://www.youtube.com/user/SomeUser')).toBe(true)
|
||||
expect(looksLikeChannelOrPlaylist('https://m.youtube.com/@SomeChannel')).toBe(true)
|
||||
})
|
||||
|
||||
it('flags a dedicated playlist page', () => {
|
||||
expect(looksLikeChannelOrPlaylist('https://www.youtube.com/playlist?list=PL123')).toBe(true)
|
||||
expect(looksLikeChannelOrPlaylist('https://music.youtube.com/playlist?list=PL123')).toBe(true)
|
||||
})
|
||||
|
||||
it('does not flag single videos, even inside a playlist context', () => {
|
||||
// A /watch video belongs in the Downloads bar, not the Library — even with a list.
|
||||
expect(looksLikeChannelOrPlaylist('https://www.youtube.com/watch?v=abc')).toBe(false)
|
||||
expect(looksLikeChannelOrPlaylist('https://www.youtube.com/watch?v=abc&list=PL123')).toBe(false)
|
||||
expect(looksLikeChannelOrPlaylist('https://youtu.be/dQw4w9WgXcQ')).toBe(false)
|
||||
})
|
||||
|
||||
it('does not flag non-YouTube hosts or a bare playlist path without a list', () => {
|
||||
expect(looksLikeChannelOrPlaylist('https://vimeo.com/channels/staffpicks')).toBe(false)
|
||||
expect(looksLikeChannelOrPlaylist('https://example.com/@handle')).toBe(false)
|
||||
expect(looksLikeChannelOrPlaylist('https://www.youtube.com/playlist')).toBe(false)
|
||||
})
|
||||
|
||||
it('returns false for non-URLs', () => {
|
||||
expect(looksLikeChannelOrPlaylist('not a url')).toBe(false)
|
||||
expect(looksLikeChannelOrPlaylist('')).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user