diff options
| author | Oleg Yakovenko <[email protected]> | 2022-02-07 10:35:21 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-02-07 10:35:21 +0200 |
| commit | f957baf68aae6ec06e94b5b7b4b1d281ab295ab3 (patch) | |
| tree | 00cca6551838ca48dc297dd71338c14d8f8467b0 /test/drawing | |
| parent | af8fbd4d095589d31494b6f04ef07ca93de89650 (diff) | |
| parent | 196862524f94c58b1521ef84a6cf0397b411a685 (diff) | |
| download | caxlsx-f957baf68aae6ec06e94b5b7b4b1d281ab295ab3.tar.gz caxlsx-f957baf68aae6ec06e94b5b7b4b1d281ab295ab3.zip | |
Merge branch 'master' into feature/manageable-scatter-markers
Diffstat (limited to 'test/drawing')
| -rw-r--r-- | test/drawing/tc_bar_3D_chart.rb | 37 | ||||
| -rw-r--r-- | test/drawing/tc_bar_chart.rb | 37 | ||||
| -rw-r--r-- | test/drawing/tc_bar_series.rb | 11 |
3 files changed, 62 insertions, 23 deletions
diff --git a/test/drawing/tc_bar_3D_chart.rb b/test/drawing/tc_bar_3D_chart.rb index 0cae7af6..b7a1eca4 100644 --- a/test/drawing/tc_bar_3D_chart.rb +++ b/test/drawing/tc_bar_3D_chart.rb @@ -32,18 +32,19 @@ class TestBar3DChart < Test::Unit::TestCase assert(@chart.grouping == :standard) end + def test_gap_width + assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = -1 } + assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 501 } + assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = 200 } + assert_equal(@chart.gap_width, 200, 'gap width is incorrect') + end - def test_gapWidth - assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 200 } - assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = "200%" } - assert(@chart.gap_width == "200%") - end - - def test_gapDepth - assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 200 } - assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = "200%" } - assert(@chart.gap_depth == "200%") - end + def test_gap_depth + assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = -1 } + assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 501 } + assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = 200 } + assert_equal(@chart.gap_depth, 200, 'gap depth is incorrect') + end def test_shape assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star } @@ -68,4 +69,18 @@ class TestBar3DChart < Test::Unit::TestCase val_axis_position = str.index(@chart.axes[:val_axis].id.to_s) assert(cat_axis_position < val_axis_position, "cat_axis must occur earlier than val_axis in the XML") end + + def test_to_xml_string_has_gap_depth + gap_depth_value = rand(0..500) + @chart.gap_depth = gap_depth_value + doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(doc.xpath("//c:bar3DChart/c:gapDepth").first.attribute('val').value, gap_depth_value.to_s) + end + + def test_to_xml_string_has_gap_width + gap_width_value = rand(0..500) + @chart.gap_width = gap_width_value + doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(doc.xpath("//c:bar3DChart/c:gapWidth").first.attribute('val').value, gap_width_value.to_s) + end end diff --git a/test/drawing/tc_bar_chart.rb b/test/drawing/tc_bar_chart.rb index ca1ca016..c8bdc8d0 100644 --- a/test/drawing/tc_bar_chart.rb +++ b/test/drawing/tc_bar_chart.rb @@ -32,18 +32,19 @@ class TestBarChart < Test::Unit::TestCase assert(@chart.grouping == :standard) end + def test_gap_width + assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = -1 } + assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 501 } + assert_nothing_raised("allow valid gap width") { @chart.gap_width = 200 } + assert_equal(@chart.gap_width, 200, 'gap width is incorrect') + end - def test_gapWidth - assert_raise(ArgumentError, "require valid gap width") { @chart.gap_width = 200 } - assert_nothing_raised("allow valid gapWidth") { @chart.gap_width = "200%" } - assert(@chart.gap_width == "200%") - end - - def test_gapDepth - assert_raise(ArgumentError, "require valid gap_depth") { @chart.gap_depth = 200 } - assert_nothing_raised("allow valid gap_depth") { @chart.gap_depth = "200%" } - assert(@chart.gap_depth == "200%") - end + def test_overlap + assert_raise(ArgumentError, "require valid overlap") { @chart.overlap = -101 } + assert_raise(ArgumentError, "require valid overlap") { @chart.overlap = 101 } + assert_nothing_raised("allow valid overlap") { @chart.overlap = 100 } + assert_equal(@chart.overlap, 100, 'overlap is incorrect') + end def test_shape assert_raise(ArgumentError, "require valid shape") { @chart.shape = :star } @@ -68,4 +69,18 @@ class TestBarChart < Test::Unit::TestCase val_axis_position = str.index(@chart.axes[:val_axis].id.to_s) assert(cat_axis_position < val_axis_position, "cat_axis must occur earlier than val_axis in the XML") end + + def test_to_xml_string_has_gap_width + gap_width_value = rand(0..500) + @chart.gap_width = gap_width_value + doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(doc.xpath("//c:barChart/c:gapWidth").first.attribute('val').value, gap_width_value.to_s) + end + + def test_to_xml_string_has_overlap + overlap_value = rand(-100..100) + @chart.overlap = overlap_value + doc = Nokogiri::XML(@chart.to_xml_string) + assert_equal(doc.xpath("//c:barChart/c:overlap").first.attribute('val').value, overlap_value.to_s) + end end diff --git a/test/drawing/tc_bar_series.rb b/test/drawing/tc_bar_series.rb index 483e561d..f076fae0 100644 --- a/test/drawing/tc_bar_series.rb +++ b/test/drawing/tc_bar_series.rb @@ -6,13 +6,21 @@ class TestBarSeries < Test::Unit::TestCase p = Axlsx::Package.new @ws = p.workbook.add_worksheet :name=>"hmmm" @chart = @ws.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 + @series = @chart.add_series( + data: [0, 1, 2], + labels: ['zero', 'one', 'two'], + title: 'bob', + colors: ['FF0000', '00FF00', '0000FF'], + shape: :cone, + series_color: '5A5A5A' + ) end def test_initialize assert_equal(@series.title.text, "bob", "series title has been applied") assert_equal(@series.data.class, Axlsx::NumDataSource, "data option applied") assert_equal(@series.shape, :cone, "series shape has been applied") + assert_equal(@series.series_color, '5A5A5A', 'series color has been applied') assert(@series.data.is_a?(Axlsx::NumDataSource)) assert(@series.labels.is_a?(Axlsx::AxDataSource)) end @@ -33,5 +41,6 @@ class TestBarSeries < Test::Unit::TestCase 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:spPr[not(ancestor::c:dPt)]/a:solidFill/a:srgbClr').first.get_attribute('val'), '5A5A5A', 'series color has been applied') end end |
