test_thumbnail.rb 910 B

1234567891011121314151617181920212223242526272829
  1. require "test_helper"
  2. class TestThumbnail < Minitest::Test
  3. def setup
  4. @jpg_path = File.expand_path("../fixtures/cockapoo.jpg", __FILE__)
  5. @heic_path = File.expand_path("../fixtures/mammoth.heic", __FILE__)
  6. @jpg_asset = Fotos::Asset.new(@jpg_path)
  7. @heic_asset = Fotos::Asset.new(@heic_path)
  8. end
  9. def test_create_thumbnail_from_jpg
  10. target_path = Fotos::Thumbnail.new(@jpg_asset).create()
  11. thumbnail = Fotos::Asset.new(target_path)
  12. assert_equal Fotos::Thumbnail::WIDTH, thumbnail.image.get('width')
  13. # clean up previously created thumbnail
  14. File.unlink thumbnail.path
  15. end
  16. def test_create_thumbnail_from_heic
  17. target_path = Fotos::Thumbnail.new(@heic_asset).create()
  18. thumbnail = Fotos::Asset.new(target_path)
  19. assert Fotos::Thumbnail::WIDTH >= thumbnail.image.get('width')
  20. # clean up previously created thumbnail
  21. File.unlink thumbnail.path
  22. end
  23. end