test: add buildChapterDownloadLink regression cases for blank audio host
Mirrors the buildDownloadLink coverage for the chapter link builder, which shares the same PUBLIC_HOST_URL fallback. Verified red against the unfixed chapter path. Addresses CodeRabbit review feedback on PR #1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2598f80835
commit
c6d83b272c
1 changed files with 24 additions and 0 deletions
|
|
@ -305,6 +305,30 @@ describe('App', () => {
|
|||
expect(app.buildDownloadLink(makeDownload())).toBe('song.mp3');
|
||||
});
|
||||
|
||||
it('builds chapter audio link from PUBLIC_HOST_AUDIO_URL when set', () => {
|
||||
downloads.configuration['PUBLIC_HOST_URL'] = 'download/';
|
||||
downloads.configuration['PUBLIC_HOST_AUDIO_URL'] = 'audio_download/';
|
||||
const app = TestBed.createComponent(App).componentInstance;
|
||||
const link = app.buildChapterDownloadLink(makeDownload(), 'chapter1.mp3');
|
||||
expect(link).toBe('audio_download/chapter1.mp3');
|
||||
});
|
||||
|
||||
it('chapter audio link falls back to PUBLIC_HOST_URL when audio host is blank (regression)', () => {
|
||||
downloads.configuration['PUBLIC_HOST_URL'] = 'download/';
|
||||
downloads.configuration['PUBLIC_HOST_AUDIO_URL'] = '';
|
||||
const app = TestBed.createComponent(App).componentInstance;
|
||||
const link = app.buildChapterDownloadLink(makeDownload(), 'chapter1.mp3');
|
||||
expect(link).not.toBe('chapter1.mp3');
|
||||
expect(link).toBe('download/chapter1.mp3');
|
||||
});
|
||||
|
||||
it('chapter audio link stays root-relative when both hosts are blank', () => {
|
||||
downloads.configuration['PUBLIC_HOST_URL'] = '';
|
||||
downloads.configuration['PUBLIC_HOST_AUDIO_URL'] = '';
|
||||
const app = TestBed.createComponent(App).componentInstance;
|
||||
expect(app.buildChapterDownloadLink(makeDownload(), 'chapter1.mp3')).toBe('chapter1.mp3');
|
||||
});
|
||||
|
||||
it('blocks subscribe with invalid title regex', () => {
|
||||
const alertSpy = vi.spyOn(window, 'alert').mockImplementation(() => undefined);
|
||||
const fixture = TestBed.createComponent(App);
|
||||
|
|
|
|||
Loading…
Reference in a new issue