diff options
| author | Koza <[email protected]> | 2023-04-12 17:33:59 +0200 |
|---|---|---|
| committer | Koza <[email protected]> | 2023-04-12 17:33:59 +0200 |
| commit | 2d714298a462a1482bd8e12fbb2efb74d6acee5f (patch) | |
| tree | c377925f9f0ea9106d3c7d808130863c11a6ce63 /test | |
| parent | e548f377932207130cec4ac257a3907385d547d5 (diff) | |
| parent | 518e74f8769daf67fca461139d3c7229abdb6e60 (diff) | |
| download | caxlsx-2d714298a462a1482bd8e12fbb2efb74d6acee5f.tar.gz caxlsx-2d714298a462a1482bd8e12fbb2efb74d6acee5f.zip | |
Merge branch 'feature/remote_images_support'
Diffstat (limited to 'test')
| -rw-r--r-- | test/drawing/tc_pic.rb | 17 | ||||
| -rw-r--r-- | test/util/tc_mime_type_utils.rb | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb index 56042de5..34f24eb3 100644 --- a/test/drawing/tc_pic.rb +++ b/test/drawing/tc_pic.rb @@ -8,7 +8,10 @@ class TestPic < Test::Unit::TestCase @test_img_png = File.dirname(__FILE__) + "/../fixtures/image1.png" @test_img_gif = File.dirname(__FILE__) + "/../fixtures/image1.gif" @test_img_fake = File.dirname(__FILE__) + "/../fixtures/image1_fake.jpg" + @test_img_remote_png = "https://via.placeholder.com/150.png" + @test_img_remote_fake = "invalid_URI" @image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5 + @image_remote = ws.add_image :image_src => @test_img_remote_png, remote: true, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?", :opacity => 5 end def test_initialization @@ -17,6 +20,13 @@ class TestPic < Test::Unit::TestCase assert_equal(@image.image_src, @test_img) end + def test_remote_img_initialization + assert_equal(@p.workbook.images[1], @image_remote) + assert_equal(@image_remote.file_name, nil) + assert_equal(@image_remote.image_src, @test_img_remote_png) + assert_equal(@image_remote.remote?, true) + end + def test_anchor_swapping # swap from one cell to two cell when end_at is specified assert(@image.anchor.is_a?(Axlsx::OneCellAnchor)) @@ -76,6 +86,13 @@ class TestPic < Test::Unit::TestCase assert_equal(@image.image_src, @test_img_jpg) end + def test_remote_image_src + assert_raise(ArgumentError) { @image_remote.image_src = @test_img_fake } + assert_raise(ArgumentError) { @image_remote.image_src = @test_img_remote_fake } + assert_nothing_raised { @image_remote.image_src = @test_img_remote_png } + assert_equal(@image_remote.image_src, @test_img_remote_png) + end + def test_descr assert_raise(ArgumentError) { @image.descr = 49 } assert_nothing_raised { @image.descr = "test" } diff --git a/test/util/tc_mime_type_utils.rb b/test/util/tc_mime_type_utils.rb index cfeec9d3..9d116931 100644 --- a/test/util/tc_mime_type_utils.rb +++ b/test/util/tc_mime_type_utils.rb @@ -2,6 +2,7 @@ require 'tc_helper.rb' class TestMimeTypeUtils < Test::Unit::TestCase def setup @test_img = File.dirname(__FILE__) + "/../fixtures/image1.jpeg" + @test_img_url = "https://via.placeholder.com/150.png" end def teardown @@ -9,5 +10,6 @@ class TestMimeTypeUtils < Test::Unit::TestCase def test_mime_type_utils assert_equal(Axlsx::MimeTypeUtils::get_mime_type(@test_img), 'image/jpeg') + assert_equal(Axlsx::MimeTypeUtils::get_mime_type_from_uri(@test_img_url), 'image/png') end end |
