mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
This commit is contained in:
@@ -1,5 +1,69 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { artistBucketKey, compareBuckets, OTHER_BUCKET, ALPHABET } from './artistsHelpers';
|
||||
import {
|
||||
artistBucketKey,
|
||||
artistLetterBucket,
|
||||
compareBuckets,
|
||||
DEFAULT_IGNORED_ARTICLES,
|
||||
OTHER_BUCKET,
|
||||
ALPHABET,
|
||||
sortKeyFromDisplayName,
|
||||
stripLeadingArticles,
|
||||
} from './artistsHelpers';
|
||||
|
||||
describe('stripLeadingArticles', () => {
|
||||
it('strips The from Beatles', () => {
|
||||
expect(stripLeadingArticles('The Beatles', DEFAULT_IGNORED_ARTICLES)).toBe('Beatles');
|
||||
});
|
||||
|
||||
it('strips The from Kinks', () => {
|
||||
expect(stripLeadingArticles('The Kinks', DEFAULT_IGNORED_ARTICLES)).toBe('Kinks');
|
||||
});
|
||||
|
||||
it('honours a custom ignoredArticles list', () => {
|
||||
expect(stripLeadingArticles('Los Lobos', 'Los')).toBe('Lobos');
|
||||
});
|
||||
});
|
||||
|
||||
describe('sortKeyFromDisplayName', () => {
|
||||
it('strips articles and lowercases', () => {
|
||||
expect(sortKeyFromDisplayName('The Beatles')).toBe('beatles');
|
||||
});
|
||||
});
|
||||
|
||||
describe('artistLetterBucket', () => {
|
||||
it('buckets a browse row by its display name, ignoring stale nameSort', () => {
|
||||
const artist = { id: '1', name: 'The Chemical Brothers', nameSort: 'the chemical brothers' };
|
||||
expect(artistLetterBucket(artist)).toBe('C');
|
||||
});
|
||||
|
||||
it('uses a server ignoredArticles override when supplied', () => {
|
||||
const artist = { id: '2', name: 'Los Lobos' };
|
||||
expect(artistLetterBucket(artist, 'Los')).toBe('L');
|
||||
});
|
||||
});
|
||||
|
||||
describe('screenshot T-filter artists (Navidrome article rules)', () => {
|
||||
it('keeps Theme/Tossers/Temper/Tiger under T after stripping The', () => {
|
||||
expect(artistBucketKey('The Theme Guys')).toBe('T');
|
||||
expect(artistBucketKey('The Tossers')).toBe('T');
|
||||
expect(artistBucketKey('The Temper Trap')).toBe('T');
|
||||
expect(artistBucketKey('The Tiger Lillies')).toBe('T');
|
||||
expect(artistBucketKey('TV Themes')).toBe('T');
|
||||
expect(artistBucketKey('Tribute To The N...')).toBe('T');
|
||||
});
|
||||
|
||||
it('moves Beatles/Chemical/Cure/Doors out of T', () => {
|
||||
expect(artistBucketKey('The Beatles')).toBe('B');
|
||||
expect(artistBucketKey('The Chemical Brothers')).toBe('C');
|
||||
expect(artistBucketKey('The Cure')).toBe('C');
|
||||
expect(artistBucketKey('The Doors')).toBe('D');
|
||||
expect(artistBucketKey('The Fat Rat')).toBe('F');
|
||||
});
|
||||
|
||||
it('keeps glued TheFatRat under T (no space after article — Navidrome parity)', () => {
|
||||
expect(artistBucketKey('TheFatRat')).toBe('T');
|
||||
});
|
||||
});
|
||||
|
||||
describe('artistBucketKey', () => {
|
||||
it('buckets A–Z names by their uppercased first letter', () => {
|
||||
@@ -8,6 +72,11 @@ describe('artistBucketKey', () => {
|
||||
expect(artistBucketKey('mGla')).toBe('M');
|
||||
});
|
||||
|
||||
it('puts The Beatles under B', () => {
|
||||
expect(artistBucketKey('The Beatles')).toBe('B');
|
||||
expect(artistBucketKey('The Kinks')).toBe('K');
|
||||
});
|
||||
|
||||
it('puts digit-leading names in #', () => {
|
||||
expect(artistBucketKey('2Pac')).toBe('#');
|
||||
expect(artistBucketKey('50 Cent')).toBe('#');
|
||||
|
||||
Reference in New Issue
Block a user