Skip to content

Commit

Permalink
add test for verify_target_images
Browse files Browse the repository at this point in the history
  • Loading branch information
kmuto committed Aug 18, 2024
1 parent 4da6e4c commit 57d5ebc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/test_epubmaker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,10 @@ def config
@config
end

def producer
@producer
end

def error(s)
raise ApplicationError, s
end
Expand Down Expand Up @@ -940,4 +944,20 @@ def test_copy_static_file
end
end
end

def test_verify_target_images
epubmaker_instance do |epubmaker, tmpdir|
epubmaker.config['epubmaker']['verify_target_images'] = true
epubmaker.config['coverimage'] = 'cover.png'

epubmaker.producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'ch01.html', title: 'CH01', level: 1)
File.write(File.join(tmpdir, 'ch01.html'), '<html><img src="images/ch01.png" /></html>')
epubmaker.producer.contents << ReVIEW::EPUBMaker::Content.new(file: 'style.css')
File.write(File.join(tmpdir, 'style.css'), 'div { background-image: url("images/bg.jpg")}')
epubmaker.verify_target_images(tmpdir)

expect = %w(images/bg.jpg images/ch01.png images/cover.png)
assert_equal expect, epubmaker.config['epubmaker']['force_include_images']
end
end
end

0 comments on commit 57d5ebc

Please sign in to comment.