summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-09-14 17:53:00 +0900
committerRandy Morgan <[email protected]>2012-09-14 17:53:00 +0900
commit3e4ee23a46c12f1a634f2cadee1798b0cb1000ff (patch)
tree49c8d888a2131740c2765d95b96c391fd90078b8 /test
parent46a9ee40524b2485155361a728fde7d35d687066 (diff)
downloadcaxlsx-3e4ee23a46c12f1a634f2cadee1798b0cb1000ff.tar.gz
caxlsx-3e4ee23a46c12f1a634f2cadee1798b0cb1000ff.zip
Implement table style info for named tables.
Diffstat (limited to 'test')
-rw-r--r--test/workbook/worksheet/table/tc_table.rb7
-rw-r--r--test/workbook/worksheet/table/tc_table_style_info.rb53
2 files changed, 59 insertions, 1 deletions
diff --git a/test/workbook/worksheet/table/tc_table.rb b/test/workbook/worksheet/table/tc_table.rb
index 7c87c69e..de86b886 100644
--- a/test/workbook/worksheet/table/tc_table.rb
+++ b/test/workbook/worksheet/table/tc_table.rb
@@ -15,6 +15,12 @@ class TestTable < Test::Unit::TestCase
end
+ def test_table_style_info
+ table = @ws.add_table('A1:D5', :name => 'foo', :style_info => { :show_row_stripes => true, :name => "TableStyleMedium25" })
+ assert_equal('TableStyleMedium25', table.table_style_info.name)
+ assert_equal(true, table.table_style_info.show_row_stripes)
+ end
+
def test_add_table
name = "test"
table = @ws.add_table("A1:D5", :name => name)
@@ -22,7 +28,6 @@ class TestTable < Test::Unit::TestCase
assert_equal(@ws.workbook.tables.last, table, "must be added to workbook table collection")
assert_equal(@ws.tables.last, table, "must be added to worksheet table collection")
assert_equal(table.name, name, "options for name are applied")
-
end
def test_pn
diff --git a/test/workbook/worksheet/table/tc_table_style_info.rb b/test/workbook/worksheet/table/tc_table_style_info.rb
new file mode 100644
index 00000000..c0c452c9
--- /dev/null
+++ b/test/workbook/worksheet/table/tc_table_style_info.rb
@@ -0,0 +1,53 @@
+require 'tc_helper.rb'
+
+class TestTableStyleInfo < Test::Unit::TestCase
+ def setup
+ p = Axlsx::Package.new
+ @ws = p.workbook.add_worksheet
+ 40.times do
+ @ws.add_row %w(aa bb cc dd ee ff gg hh ii jj kk)
+ end
+ @table = @ws.add_table(Axlsx::cell_range([@ws.rows.first.cells.first,@ws.rows.last.cells.last], false), :name => 'foo')
+ @options = { :show_first_column => 1,
+ :show_last_column => 1,
+ :show_row_stripes => 1,
+ :show_column_stripes => 1,
+ :name => "TableStyleDark4" }
+
+
+ end
+
+ def test_initialize
+ table_style = Axlsx::TableStyleInfo.new @options
+ @options.each do |key, value|
+ assert_equal(value, table_style.send(key.to_sym))
+ end
+ end
+
+ def test_boolean_properties
+ table_style = Axlsx::TableStyleInfo.new
+ @options.keys.each do |key|
+ assert_nothing_raised { table_style.send("#{key.to_sym}=", true) }
+ assert_raises(ArgumentError) { table_style.send(key.to_sym, 'foo') }
+ end
+ end
+ def doc
+ @doc ||= Nokogiri::XML(Axlsx::TableStyleInfo.new(@options).to_xml_string)
+ end
+
+ def test_to_xml_string_first_column
+ assert(doc.xpath('//tableStyleInfo[@showLastColumn=1]'))
+ end
+
+ def test_to_xml_string_row_stripes
+ assert(doc.xpath('//tableStyleInfo[@showRowStripes=1]'))
+ end
+
+ def test_to_xml_string_column_stripes
+ assert(doc.xpath('//tableStyleInfo[@showColumnStripes=1]'))
+ end
+
+ def test_to_xml_string_name
+ assert(doc.xpath("//tableStyleInfo[@name=#{@options[:name]}]"))
+ end
+end