test/workbook/worksheet/tc_worksheet.rb in axlsx-2.1.0.pre vs test/workbook/worksheet/tc_worksheet.rb in axlsx-3.0.0.pre
- old
+ new
@@ -91,11 +91,11 @@
def test_initialization_options
page_margins = {:left => 2, :right => 2, :bottom => 2, :top => 2, :header => 2, :footer => 2}
page_setup = {:fit_to_height => 1, :fit_to_width => 1, :orientation => :landscape, :paper_width => "210mm", :paper_height => "297mm", :scale => 80}
print_options = {:grid_lines => true, :headings => true, :horizontal_centered => true, :vertical_centered => true}
header_footer = {:different_first => false, :different_odd_even => false, :odd_header => 'Header'}
- optioned = @ws.workbook.add_worksheet(:name => 'bob', :page_margins => page_margins, :page_setup => page_setup, :print_options => print_options, :header_footer => header_footer, :selected => true, :show_gridlines => false)
+ optioned = @ws.workbook.add_worksheet(:name => 'bob', :page_margins => page_margins, :page_setup => page_setup, :print_options => print_options, :header_footer => header_footer)
page_margins.keys.each do |key|
assert_equal(page_margins[key], optioned.page_margins.send(key))
end
page_setup.keys.each do |key|
assert_equal(page_setup[key], optioned.page_setup.send(key))
@@ -105,27 +105,25 @@
end
header_footer.keys.each do |key|
assert_equal(header_footer[key], optioned.header_footer.send(key))
end
assert_equal(optioned.name, 'bob')
- assert_equal(optioned.selected, true)
- assert_equal(optioned.show_gridlines, false)
end
- def test_use_gridlines
- assert_raise(ArgumentError) { @ws.show_gridlines = -1.1 }
- assert_nothing_raised { @ws.show_gridlines = false }
- assert_equal(@ws.show_gridlines, false)
- end
+ # def test_use_gridlines
+ # assert_raise(ArgumentError) { @ws.show_gridlines = -1.1 }
+ # assert_nothing_raised { @ws.show_gridlines = false }
+ # assert_equal(@ws.show_gridlines, false)
+ # end
- def test_selected
- assert_raise(ArgumentError) { @ws.selected = -1.1 }
- assert_nothing_raised { @ws.selected = true }
- assert_equal(@ws.selected, true)
- end
+ # def test_selected
+ # assert_raise(ArgumentError) { @ws.selected = -1.1 }
+ # assert_nothing_raised { @ws.selected = true }
+ # assert_equal(@ws.selected, true)
+ # end
def test_rels_pn
assert_equal(@ws.rels_pn, "worksheets/_rels/sheet1.xml.rels")
ws = @ws.workbook.add_worksheet
assert_equal(ws.rels_pn, "worksheets/_rels/sheet2.xml.rels")
@@ -264,38 +262,38 @@
assert_equal(c.style, 1)
end
end
end
- def test_to_xml_string_fit_to_page
- @ws.page_setup.fit_to_width = 1
- doc = Nokogiri::XML(@ws.to_xml_string)
- assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:pageSetUpPr[@fitToPage=1]').size, 1)
- end
+ # def test_to_xml_string_fit_to_page
+ # @ws.page_setup.fit_to_width = 1
+ # doc = Nokogiri::XML(@ws.to_xml_string)
+ # assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:pageSetUpPr[@fitToPage=1]').size, 1)
+ # end
def test_to_xml_string_dimensions
@ws.add_row [1,2,3]
doc = Nokogiri::XML(@ws.to_xml_string)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:dimension[@ref="A1:C1"]').size, 1)
end
- def test_fit_to_page_assignation_does_nothing
- @ws.fit_to_page = true
- assert_equal(@ws.fit_to_page?, false)
- end
+ # def test_fit_to_page_assignation_does_nothing
+ # @ws.fit_to_page = true
+ # assert_equal(@ws.fit_to_page?, false)
+ # end
- def test_to_xml_string_selected
- @ws.selected = true
- doc = Nokogiri::XML(@ws.to_xml_string)
- assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@tabSelected=1]').size, 1)
- end
+ # def test_to_xml_string_selected
+ # @ws.selected = true
+ # doc = Nokogiri::XML(@ws.to_xml_string)
+ # assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@tabSelected=1]').size, 1)
+ # end
- def test_to_xml_string_show_gridlines
- @ws.show_gridlines = false
- doc = Nokogiri::XML(@ws.to_xml_string)
- assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@showGridLines=0]').size, 1)
- end
+ # def test_to_xml_string_show_gridlines
+ # @ws.show_gridlines = false
+ # doc = Nokogiri::XML(@ws.to_xml_string)
+ # assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetViews/xmlns:sheetView[@showGridLines=0]').size, 1)
+ # end
def test_to_xml_string_auto_fit_data
@ws.add_row [1, "two"]
doc = Nokogiri::XML(@ws.to_xml_string)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:cols/xmlns:col').size, 2)
@@ -321,10 +319,17 @@
doc = Nokogiri::XML(@ws.to_xml_string)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:mergeCells/xmlns:mergeCell[@ref="A1:D1"]').size, 1)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:mergeCells/xmlns:mergeCell[@ref="E1:F1"]').size, 1)
end
+ def test_to_xml_string_merge_cells_row
+ row = @ws.add_row [1, "two"]
+ @ws.merge_cells row
+ doc = Nokogiri::XML(@ws.to_xml_string)
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:mergeCells/xmlns:mergeCell[@ref="A1:B1"]').size, 1)
+ end
+
def test_to_xml_string_row_breaks
@ws.add_page_break("A1")
doc = Nokogiri::XML(@ws.to_xml_string)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:rowBreaks/xmlns:brk[@id="0"]').size, 1)
end
@@ -430,19 +435,19 @@
end
def test_relationships
@ws.add_row [1,2,3]
assert(@ws.relationships.empty?, "No Drawing relationship until you add a chart")
- c = @ws.add_chart Axlsx::Pie3DChart
+ @ws.add_chart Axlsx::Pie3DChart
assert_equal(@ws.relationships.size, 1, "adding a chart creates the relationship")
- c = @ws.add_chart Axlsx::Pie3DChart
+ @ws.add_chart Axlsx::Pie3DChart
assert_equal(@ws.relationships.size, 1, "multiple charts still only result in one relationship")
- c = @ws.add_comment :text => 'builder', :author => 'bob', :ref => @ws.rows.last.cells.last
+ @ws.add_comment :text => 'builder', :author => 'bob', :ref => @ws.rows.last.cells.last
assert_equal(@ws.relationships.size, 3, "adding a comment adds 2 relationships")
- c = @ws.add_comment :text => 'not that is a comment!', :author => 'travis', :ref => "A1"
+ @ws.add_comment :text => 'not that is a comment!', :author => 'travis', :ref => "A1"
assert_equal(@ws.relationships.size, 3, "adding multiple comments in the same worksheet should not add any additional comment relationships")
- c = @ws.add_pivot_table 'G5:G6', 'A1:D10'
+ @ws.add_pivot_table 'G5:G6', 'A1:D10'
assert_equal(@ws.relationships.size, 4, "adding a pivot table adds 1 relationship")
end
def test_name_unique
@@ -474,11 +479,11 @@
def test_set_column_width
@ws.add_row ["chasing windmills", "penut"]
@ws.column_widths nil, 0.5
assert_equal(@ws.column_info[1].width, 0.5, 'eat my width')
assert_raise(ArgumentError, 'only accept unsigned ints') { @ws.column_widths 2, 7, -1 }
- assert_raise(ArgumentError, 'only accept Integer, Float or Fixnum') { @ws.column_widths 2, 7, "-1" }
+ assert_raise(ArgumentError, 'only accept Integer or Float') { @ws.column_widths 2, 7, "-1" }
end
def test_protect_range
assert(@ws.send(:protected_ranges).is_a?(Axlsx::SimpleTypedList))
assert_equal(0, @ws.send(:protected_ranges).size)
@@ -572,6 +577,16 @@
assert_equal(1, @wb.worksheets.size)
assert_raise(ArgumentError) { @wb.add_worksheet(:name => 'Sheet1') }
assert_equal(1, @wb.worksheets.size)
end
+ def test_worksheet_only_includes_outline_pr_when_set
+ doc = Nokogiri::XML(@ws.to_xml_string)
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:outlinePr').size, 0)
+
+ @ws.sheet_pr.outline_pr.summary_below = false
+ @ws.sheet_pr.outline_pr.summary_right = true
+ doc = Nokogiri::XML(@ws.to_xml_string)
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:outlinePr').size, 1)
+ assert_equal(doc.xpath('//xmlns:worksheet/xmlns:sheetPr/xmlns:outlinePr[@summaryBelow=0][@summaryRight=1]').size, 1)
+ end
end