diff options
| author | Jonathan Tron <[email protected]> | 2015-07-05 15:40:01 +0200 |
|---|---|---|
| committer | Jonathan Tron <[email protected]> | 2015-07-05 15:41:55 +0200 |
| commit | f0f372165beb37a6d91f6c98bc9b2268cb4eda74 (patch) | |
| tree | 3c506ee6d5b9e39f4680b7b135b111a27e659b81 /test/drawing | |
| parent | e36dbc979496d6e95667804cafb9448046912c1b (diff) | |
| download | caxlsx-f0f372165beb37a6d91f6c98bc9b2268cb4eda74.tar.gz caxlsx-f0f372165beb37a6d91f6c98bc9b2268cb4eda74.zip | |
Fix Axlsx::LineSeries#marker_symbol and add tests
Diffstat (limited to 'test/drawing')
| -rw-r--r-- | test/drawing/tc_line_series.rb | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/test/drawing/tc_line_series.rb b/test/drawing/tc_line_series.rb index 3d023a12..d939096f 100644 --- a/test/drawing/tc_line_series.rb +++ b/test/drawing/tc_line_series.rb @@ -6,14 +6,20 @@ class TestLineSeries < Test::Unit::TestCase p = Axlsx::Package.new @ws = p.workbook.add_worksheet :name=>"hmmm" chart = @ws.add_chart Axlsx::Line3DChart, :title => "fishery" - @series = chart.add_series :data=>[0,1,2], :labels=>["zero", "one", "two"], :title=>"bob", :color => "#FF0000", :show_marker => true, :smooth => true + @series = chart.add_series( + :data => [0,1,2], + :labels => ["zero", "one", "two"], + :title => "bob", + :color => "#FF0000", + :show_marker => true, + :smooth => true + ) end def test_initialize assert_equal(@series.title.text, "bob", "series title has been applied") assert_equal(@series.labels.class, Axlsx::AxDataSource) assert_equal(@series.data.class, Axlsx::NumDataSource) - end def test_show_marker @@ -28,11 +34,38 @@ class TestLineSeries < Test::Unit::TestCase assert_equal(false, @series.smooth) end + def test_marker_symbol + assert_equal(:default, @series.marker_symbol) + @series.marker_symbol = :circle + assert_equal(:circle, @series.marker_symbol) + end + def test_to_xml_string - doc = Nokogiri::XML(@series.to_xml_string) + doc = Nokogiri::XML(wrap_with_namespaces(@series)) assert(doc.xpath("//srgbClr[@val='#{@series.color}']")) - assert(doc.xpath("//marker")) + assert_equal(xpath_with_namespaces(doc, "//c:marker").size, 0) assert(doc.xpath("//smooth")) + + @series.marker_symbol = :diamond + doc = Nokogiri::XML(wrap_with_namespaces(@series)) + assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='diamond']").size, 1) + + @series.show_marker = false + doc = Nokogiri::XML(wrap_with_namespaces(@series)) + assert_equal(xpath_with_namespaces(doc, "//c:marker/c:symbol[@val='none']").size, 1) + end + + def wrap_with_namespaces(series) + '<c:chartSpace xmlns:c="' << + Axlsx::XML_NS_C << + '" xmlns:a="' << + Axlsx::XML_NS_A << + '">' << + series.to_xml_string << + '</c:chartSpace>' + end + + def xpath_with_namespaces(doc, xpath) + doc.xpath(xpath, "a" => Axlsx::XML_NS_A, "c" => Axlsx::XML_NS_C) end - #TODO serialization testing end |
