test/drawing/tc_pic.rb in axlsx-1.3.6 vs test/drawing/tc_pic.rb in axlsx-2.0.0
- old
+ new
@@ -4,10 +4,11 @@
def setup
@p = Axlsx::Package.new
ws = @p.workbook.add_worksheet
@test_img = File.dirname(__FILE__) + "/../../examples/image1.jpeg"
+ @test_img_up = File.dirname(__FILE__) + "/../../examples/IMAGE1UP.JPEG"
@image = ws.add_image :image_src => @test_img, :hyperlink => 'https://github.com/randym', :tooltip => "What's up doc?"
end
def teardown
end
@@ -19,25 +20,25 @@
end
def test_anchor_swapping
#swap from one cell to two cell when end_at is specified
assert(@image.anchor.is_a?(Axlsx::OneCellAnchor))
- start_at = @image.anchor.from
+ start_at = @image.anchor.from
@image.end_at 10,5
assert(@image.anchor.is_a?(Axlsx::TwoCellAnchor))
assert_equal(start_at.col, @image.anchor.from.col)
assert_equal(start_at.row, @image.anchor.from.row)
assert_equal(10,@image.anchor.to.col)
assert_equal(5, @image.anchor.to.row)
-
+
#swap from two cell to one cell when width or height are specified
@image.width = 200
assert(@image.anchor.is_a?(Axlsx::OneCellAnchor))
assert_equal(start_at.col, @image.anchor.from.col)
assert_equal(start_at.row, @image.anchor.from.row)
assert_equal(200, @image.width)
-
+
end
def test_hyperlink
assert_equal(@image.hyperlink.href, "https://github.com/randym")
@image.hyperlink = "http://axlsx.blogspot.com"
assert_equal(@image.hyperlink.href, "http://axlsx.blogspot.com")
@@ -74,10 +75,14 @@
assert_raise(ArgumentError) { @image.image_src = __FILE__ }
assert_nothing_raised { @image.image_src = @test_img }
assert_equal(@image.image_src, @test_img)
end
+ def test_image_src_downcase
+ assert_nothing_raised { @image.image_src = @test_img_up }
+ end
+
def test_descr
assert_raise(ArgumentError) { @image.descr = 49 }
assert_nothing_raised { @image.descr = "test" }
assert_equal(@image.descr, "test")
end
@@ -89,8 +94,14 @@
schema.validate(doc).each do |error|
errors.push error
puts error.message
end
assert(errors.empty?, "error free validation")
+ end
+
+ def test_to_xml_has_correct_r_id
+ r_id = @image.anchor.drawing.relationships.for(@image).Id
+ doc = Nokogiri::XML(@image.anchor.drawing.to_xml_string)
+ assert_equal r_id, doc.xpath("//a:blip").first["r:embed"]
end
end