diff options
| author | Sebastiano <[email protected]> | 2023-01-17 14:55:35 +0100 |
|---|---|---|
| committer | Koza <[email protected]> | 2023-04-12 17:27:52 +0200 |
| commit | f91cf59d7a62643140378e601f0a11a4deb23465 (patch) | |
| tree | 612757024b7efb73d81d62402a56c347000108f8 /test/drawing | |
| parent | 9bd3367b35bcc85f74c749cfbab05e9c430ab064 (diff) | |
| download | caxlsx-f91cf59d7a62643140378e601f0a11a4deb23465.tar.gz caxlsx-f91cf59d7a62643140378e601f0a11a4deb23465.zip | |
improve validation
add test cases
Diffstat (limited to 'test/drawing')
| -rw-r--r-- | test/drawing/tc_pic.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/drawing/tc_pic.rb b/test/drawing/tc_pic.rb index 56042de5..aa4d6af7 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) + 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,14 @@ 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" } |
