summaryrefslogtreecommitdiffhomepage
path: root/test/drawing/tc_bar_series.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-04-28 11:57:23 +0900
committerRandy Morgan <[email protected]>2012-04-28 11:57:23 +0900
commit66c92d008b3caa0223627ea2de13a75fb6b90701 (patch)
tree29037f687453a2ec0d4d8f424f16a17ebe37f068 /test/drawing/tc_bar_series.rb
parent3179631b7a75ae490a20b41950ecf59c25b01130 (diff)
downloadcaxlsx-66c92d008b3caa0223627ea2de13a75fb6b90701.tar.gz
caxlsx-66c92d008b3caa0223627ea2de13a75fb6b90701.zip
specs for color and series changes
Diffstat (limited to 'test/drawing/tc_bar_series.rb')
-rw-r--r--test/drawing/tc_bar_series.rb22
1 files changed, 17 insertions, 5 deletions
diff --git a/test/drawing/tc_bar_series.rb b/test/drawing/tc_bar_series.rb
index b07b42a4..443427c1 100644
--- a/test/drawing/tc_bar_series.rb
+++ b/test/drawing/tc_bar_series.rb
@@ -5,15 +5,19 @@ class TestBarSeries < Test::Unit::TestCase
def setup
p = Axlsx::Package.new
@ws = p.workbook.add_worksheet :name=>"hmmm"
- chart = @ws.drawing.add_chart Axlsx::Bar3DChart, :title => "fishery"
- @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob"
+ @chart = @ws.drawing.add_chart Axlsx::Bar3DChart, :title => "fishery"
+ @series = @chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob", :colors => ['FF0000', '00FF00', '0000FF'], :shape => :cone
end
def test_initialize
assert_equal(@series.title.text, "bob", "series title has been applied")
assert_equal(@series.data, [0,1,2], "data option applied")
assert_equal(@series.labels, ["zero", "one","two"], "labels option applied")
- assert_equal(@series.shape, :box, "series shape has been applied")
+ assert_equal(@series.shape, :cone, "series shape has been applied")
+ end
+
+ def test_colors
+ assert_equal(@series.colors.size, 3)
end
def test_data
@@ -26,8 +30,16 @@ class TestBarSeries < Test::Unit::TestCase
def test_shape
assert_raise(ArgumentError, "require valid shape") { @series.shape = :teardropt }
- assert_nothing_raised("allow valid shape") { @series.shape = :cone }
- assert(@series.shape == :cone)
+ assert_nothing_raised("allow valid shape") { @series.shape = :box }
+ assert(@series.shape == :box)
end
+ def test_to_xml_string
+ doc = Nokogiri::XML(@chart.to_xml_string)
+ @series.colors.each_with_index do |color, index|
+ assert_equal(doc.xpath("//c:dPt/c:idx[@val='#{index}']").size,1)
+ assert_equal(doc.xpath("//c:dPt/c:spPr/a:solidFill/a:srgbClr[@val='#{@series.colors[index]}']").size,1)
+ end
+ assert_equal(doc.xpath("//c:shape[@val='#{@series.shape.to_s}']").size, 1)
+ end
end