# frozen_string_literal: true require_relative 'spec_helper' describe 'Asciidoctor::Epub3::Converter - Xref' do context 'inter-chapter' do it 'resolves xref to top of chapter' do book, = to_epub fixture_file('inter-chapter-xref/book.adoc') chapter_a = book.item_by_href 'chapter-a.xhtml' expect(chapter_a).not_to be_nil expect(chapter_a.content).to include 'Chapter B' end it 'resolves xref to section inside chapter' do book, = to_epub fixture_file('inter-chapter-xref-to-subsection/book.adoc') chapter_a = book.item_by_href 'chapter-a.xhtml' expect(chapter_a).not_to be_nil expect(chapter_a.content).to include 'Getting Started' end end it 'resolves xref between subchapter include files' do book, = to_epub fixture_file('inter-subchapter-xref/book.adoc') chapter_a = book.item_by_href 'chapter-a.xhtml' expect(chapter_a).not_to be_nil expect(chapter_a.content).to include 'label' end it 'resolves xref to inline anchor' do book, = to_epub fixture_file('inline-anchor-xref/book.adoc') chapter = book.item_by_href 'chapter.xhtml' expect(chapter).not_to be_nil expect(chapter.content).to include 'foo::bar' expect(chapter.content).to include '[item1]' end it 'resolves xref to bibliography anchor' do book, = to_epub fixture_file('bibliography-xref/book.adoc') chapter = book.item_by_href 'chapter.xhtml' expect(chapter).not_to be_nil expect(chapter.content).to include '[item1] foo::bar' expect(chapter.content).to include '[item1]' end it 'resolves xref to bibliography chapter' do book, = to_epub fixture_file('bibliography-chapter/book.adoc') chapter = book.item_by_href 'chapter.xhtml' expect(chapter).not_to be_nil expect(chapter.content).to include '[pp]' end it 'adds xref id to paragraph' do book = to_epub <<~EOS = Article [id=one] One [[two]] Two [#three] Three More text EOS article = book.item_by_href '_article.xhtml' expect(article).not_to be_nil expect(article.content).to include '

One

' expect(article.content).to include '

Two

' expect(article.content).to include '

Three

' end it 'displays anchor text' do book = to_epub <<~EOS = Article <<_subsection,link text>> == Subsection EOS article = book.item_by_href '_article.xhtml' expect(article).not_to be_nil expect(article.content).to include 'link text' end end