summaryrefslogtreecommitdiffhomepage
path: root/test/drawing/tc_title.rb
diff options
context:
space:
mode:
authorStefan <[email protected]>2022-05-13 12:09:23 +0200
committerStefan Daschek <[email protected]>2022-05-18 13:04:15 +0200
commit228772ee37e75f0206a635178d991b2399870353 (patch)
tree8219ec07e3b79a9a8dadfcd90a8f2ebf46f25426 /test/drawing/tc_title.rb
parent39ae1467c0345ac619caa5af5e6727372d30b217 (diff)
downloadcaxlsx-228772ee37e75f0206a635178d991b2399870353.tar.gz
caxlsx-228772ee37e75f0206a635178d991b2399870353.zip
Fix missing cell reference for chart title when cell empty
Before this change, creating a chart title referencing an empty cell would lose the cell reference. If the cell was later set to a non-blank value (either during generating the file, or while editing it in a spreadsheet app), the chart title would stay blank.
Diffstat (limited to 'test/drawing/tc_title.rb')
-rw-r--r--test/drawing/tc_title.rb12
1 files changed, 11 insertions, 1 deletions
diff --git a/test/drawing/tc_title.rb b/test/drawing/tc_title.rb
index cdbd87e1..eb549b35 100644
--- a/test/drawing/tc_title.rb
+++ b/test/drawing/tc_title.rb
@@ -47,8 +47,18 @@ class TestTitle < Test::Unit::TestCase
def test_to_xml_string_cell
@chart.title.cell = @row.cells.first
doc = Nokogiri::XML(@chart.to_xml_string)
+ assert_equal("'Sheet1'!$A$1:$A$1", doc.xpath('//c:strRef/c:f').text)
assert_equal(1, doc.xpath('//c:strCache').size)
- assert_equal(1, doc.xpath('//c:v[text()="one"]').size)
+ assert_equal('one', doc.xpath('//c:strCache/c:pt//c:v').text)
+ end
+
+ def test_to_xml_string_empty_cell
+ @row.cells.first.value = ""
+ @chart.title.cell = @row.cells.first
+ doc = Nokogiri::XML(@chart.to_xml_string)
+ assert_equal("'Sheet1'!$A$1:$A$1", doc.xpath('//c:strRef/c:f').text)
+ assert_equal(1, doc.xpath('//c:strCache').size)
+ assert_equal('', doc.xpath('//c:strCache/c:pt//c:v').text)
end
def test_to_xml_string_for_special_characters