Skip to content

Commit

Permalink
[skip ci] add failing test for landmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
skoji committed Nov 6, 2018
1 parent 1a86ebc commit f6e518b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/gepub/item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def is_handler_of media_type
self
end

def landmarks(type:, title:)
self
end

# guess and set content property from contents.
def guess_content_property
if File.extname(self.href) =~ /.x?html/ && @attributes['media-type'] === 'application/xhtml+xml'
Expand Down
17 changes: 16 additions & 1 deletion spec/example_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,22 @@
book.add_item('text/chap2.xhtml').add_content(StringIO.new('<html xmlns="http://www.w3.org/1999/xhtml"><head><title>c3</title></head><body><p>the third page</p></body></html>')).toc_text('Chapter 2')
}
epubname = File.join(File.dirname(__FILE__), 'example_test.epub')
fail 'should check landmarks.'

# check nav doc
xml = Nokogiri::XML::Document.parse book.nav_doc

# check toc
tocs = xml.at_xpath("//xmlns:nav[@epub:type='toc']").xpath("//xmlns:li")
expect(tocs.size).to eq 2
expect(tocs[0].content.strip).to eq 'Chapter 1'
expect(tocs[1].content.strip).to eq 'Chapter 2'

# check landmarks
landmarks = xml.at_xpath("//xmlns:nav[@epub:type='landmarks']").xpath("//xmlns:ol/smlns:li")
expect(landmarks.size).to eq 3
expect(landmarks[0]['@epub:type']).to eq 'cover'
expect(landmarks[1]['@epub:type']).to eq 'toc'
expect(landmarks[2]['@epub:type']).to eq 'bodymatter'
book.generate_epub(epubname)
epubcheck(epubname)
end
Expand Down

0 comments on commit f6e518b

Please sign in to comment.