import { describe, expect, it } from 'vitest';
import { chatfieldSeriesLinks, parseBagwellBooks, parseChatfieldBook } from './author-adapters.js';
import { ReviewError, type SeedSeries } from './types.js';
describe('author bibliographies',()=>{
it('uses the author book number rather than a realm ordinal or paperback date',()=>{
const book=parseChatfieldBook('
The Sixth Realm Part 2 - The Ten Realms Series Book 7 - (Paperback)
PLEASE NOTE THAT YOU CANNOT PURCHASE THE PHYSICAL BOOK FROM THE STORE.
Two soldiers seek their next challenge. Danger awaits beyond the gate.
');
expect(book).toMatchObject({title:'The Sixth Realm Part 2',number:7,format:'print',releaseDate:null,audioReleaseDate:null,narrator:null,links:[]});
expect(book.description).toBe('Two soldiers seek their next challenge.\nDanger awaits beyond the gate.');
});
it('rejects unrelated products and unnumbered store pages',()=>{
expect(()=>parseChatfieldBook('
')).toThrow(ReviewError);
});
it('discovers only explicitly numbered books and ignores recommendations or offsite links',()=>{
const html='The Fourth Realm - The Ten Realms Series Book 4Other Series Book 1The Ten Realms Series Book 5';
expect(chatfieldSeriesLinks(html,'https://michaelchatfield.com/collections/the-ten-realms')).toEqual([{url:'https://michaelchatfield.com/products/realm',title:'The Fourth Realm - The Ten Realms Series Book 4'}]);
});
const seed:SeedSeries={id:'awaken-online',title:'Awaken Online',author:'Travis Bagwell',authorAliases:['Travis Bagwell'],aliases:[],genres:['litrpg'],priority:1,sources:[]};
it('retains fractional side stories and excludes separate Tarot/MRI numbering',()=>{
const card=(label:string,title:string)=>`${label}