test/workbook/worksheet/tc_worksheet.rb in axlsx-1.1.8 vs test/workbook/worksheet/tc_worksheet.rb in axlsx-1.2.0
- old
+ new
@@ -111,16 +111,16 @@
end
def test_dimension
@ws.add_row [1, 2, 3]
@ws.add_row [4, 5, 6]
- assert_equal @ws.dimension, "A1:C2"
+ assert_equal @ws.dimension.sqref, "A1:C2"
end
def test_dimension_with_empty_row
@ws.add_row
- assert_equal "A1:AA200", @ws.dimension
+ assert_equal "A1:AA200", @ws.dimension.sqref
end
def test_referencing
@ws.add_row [1, 2, 3]
@ws.add_row [4, 5, 6]
@@ -146,11 +146,13 @@
@ws.add_chart Axlsx::Pie3DChart
assert_equal(@ws.workbook.charts.size, 1, "add_chart adds a chart to the workbook")
end
def test_drawing
- assert @ws.drawing.is_a? Axlsx::Drawing
+ assert @ws.drawing == nil
+ @ws.add_chart(Axlsx::Pie3DChart)
+ assert @ws.drawing.is_a?(Axlsx::Drawing)
end
def test_col_style
@ws.add_row [1,2,3,4]
@ws.add_row [1,2,3,4]
@@ -304,22 +306,20 @@
doc = Nokogiri::XML(@ws.to_xml_string)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:tableParts[@count="1"]').size, 1)
assert_equal(doc.xpath('//xmlns:worksheet/xmlns:tableParts/xmlns:tablePart[@r:id="rId1"]').size, 1)
end
- def test_abs_auto_filter
- @ws.add_row [1, "two", 3]
- @ws.auto_filter = "A1:C1"
- assert_equal(@ws.abs_auto_filter, "'Sheet1'!$A$1:$C$1")
- end
-
def test_to_xml_string
schema = Nokogiri::XML::Schema(File.open(Axlsx::SML_XSD))
doc = Nokogiri::XML(@ws.to_xml_string)
assert(schema.validate(doc).map{ |e| puts e.message; e }.empty?, "error free validation")
end
+ def test_styles
+ assert(@ws.styles.is_a?(Axlsx::Styles), 'worksheet provides access to styles')
+ end
+
def test_to_xml_string_with_illegal_chars
nasties = "\v\u2028\u0001\u0002\u0003\u0004\u0005\u0006\u0007\u0008\u001f"
@ws.add_row [nasties]
assert_equal(0, @ws.rows.last.cells.last.value.index("\v"))
assert_equal(nil,@ws.to_xml_string.index("\v"))
@@ -363,11 +363,11 @@
end
def test_set_fixed_width_column
@ws.add_row ["mule", "donkey", "horse"], :widths => [20, :ignore, nil]
assert(@ws.column_info.size == 3, "a data item for each column")
- assert_equal(@ws.column_info[0].width, 20, "adding a row with fixed width updates :fixed attribute")
+ assert_equal(20, @ws.column_info[0].width, "adding a row with fixed width updates :fixed attribute")
assert_equal(@ws.column_info[1].width, nil, ":ignore does not set any data")
end
def test_fixed_height
@ws.add_row [1, 2, 3], :height => 40
@@ -381,45 +381,43 @@
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" }
end
def test_protect_range
- assert(@ws.protected_ranges.is_a?(Axlsx::SimpleTypedList))
- assert_equal(0, @ws.protected_ranges.size)
+ assert(@ws.send(:protected_ranges).is_a?(Axlsx::SimpleTypedList))
+ assert_equal(0, @ws.send(:protected_ranges).size)
@ws.protect_range('A1:A3')
- assert_equal('A1:A3', @ws.protected_ranges.last.sqref)
+ assert_equal('A1:A3', @ws.send(:protected_ranges).last.sqref)
end
def test_protect_range_with_cells
@ws.add_row [1, 2, 3]
assert_nothing_raised {@ws.protect_range(@ws.rows.first.cells) }
- assert_equal('A1:C1', @ws.protected_ranges.last.sqref)
+ assert_equal('A1:C1', @ws.send(:protected_ranges).last.sqref)
end
def test_merge_cells
- assert(@ws.merged_cells.is_a?(Array))
- assert_equal(@ws.merged_cells.size, 0)
@ws.add_row [1,2,3]
@ws.add_row [4,5,6]
@ws.add_row [7,8,9]
@ws.merge_cells "A1:A2"
@ws.merge_cells "B2:C3"
@ws.merge_cells @ws.rows.last.cells[(0..1)]
- assert_equal(@ws.merged_cells.size, 3)
- assert_equal(@ws.merged_cells.last, "A3:B3")
+ assert_equal(@ws.send(:merged_cells).size, 3)
+ assert_equal(@ws.send(:merged_cells).last, "A3:B3")
end
def test_merge_cells_sorts_correctly_by_row_when_given_array
10.times do |i|
@ws.add_row [i]
end
@ws.merge_cells [@ws.rows[8].cells.first, @ws.rows[9].cells.first]
- assert_equal "A9:A10", @ws.merged_cells.first
+ assert_equal "A9:A10", @ws.send(:merged_cells).first
end
def test_auto_filter
- assert(@ws.auto_filter.nil?)
+ assert(@ws.auto_filter.range.nil?)
assert_raise(ArgumentError) { @ws.auto_filter = 123 }
@ws.auto_filter = "A1:D9"
- assert_equal(@ws.auto_filter, "A1:D9")
+ assert_equal(@ws.auto_filter.range, "A1:D9")
end
end