summaryrefslogtreecommitdiffhomepage
path: root/test/workbook/worksheet/tc_col.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-03-28 23:44:15 +0900
committerRandy Morgan <[email protected]>2012-03-28 23:44:15 +0900
commitda054ee2f47261f70ebc18f133dc303acd810581 (patch)
treeb35eff352135a60b7d8a440fd0411b48a8b94369 /test/workbook/worksheet/tc_col.rb
parent30621f2ce9c88b242524929b184dfeebf89181aa (diff)
downloadcaxlsx-da054ee2f47261f70ebc18f133dc303acd810581.tar.gz
caxlsx-da054ee2f47261f70ebc18f133dc303acd810581.zip
implement column object - still needs to be tied in to a rewrite of autofit_data
Diffstat (limited to 'test/workbook/worksheet/tc_col.rb')
-rw-r--r--test/workbook/worksheet/tc_col.rb59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_col.rb b/test/workbook/worksheet/tc_col.rb
new file mode 100644
index 00000000..b28e26e9
--- /dev/null
+++ b/test/workbook/worksheet/tc_col.rb
@@ -0,0 +1,59 @@
+require 'tc_helper.rb'
+
+class TestCol < Test::Unit::TestCase
+
+ def setup
+ @col = Axlsx::Col.new 1, 1
+ end
+
+ def test_min_max_required
+ assert_raise(ArgumentError, 'min and max must be specified when creating a new column') { Axlsx::Col.new }
+ assert_raise(ArgumentError, 'min and max must be specified when creating a new column') { Axlsx::Col.new nil, nil }
+ assert_nothing_raised { Axlsx::Col.new 1, 1 }
+ end
+
+ def test_bestFit
+ assert_equal(@col.bestFit, nil)
+ assert_raise(NoMethodError, 'bestFit is read only') { @col.bestFit = 'bob' }
+ @col.width = 1.999
+ assert_equal(@col.bestFit, true, 'bestFit should be true when width has been set')
+ end
+
+ def test_collapsed
+ assert_equal(@col.collapsed, nil)
+ assert_raise(ArgumentError, 'collapsed must be boolean(ish)') { @col.collapsed = 'bob' }
+ assert_nothing_raised('collapsed must be boolean(ish)') { @col.collapsed = true }
+ end
+
+ def test_customWidth
+ assert_equal(@col.customWidth, nil)
+ @col.width = 3
+ assert_raise(NoMethodError, 'customWidth is read only') { @col.customWidth = 3 }
+ assert_equal(@col.customWidth, true, 'customWidth is true when width is set')
+ end
+
+ def test_hidden
+ assert_equal(@col.hidden, nil)
+ assert_raise(ArgumentError, 'hidden must be boolean(ish)') { @col.hidden = 'bob' }
+ assert_nothing_raised(ArgumentError, 'hidden must be boolean(ish)') { @col.hidden = true }
+ end
+
+ def test_outlineLevel
+ assert_equal(@col.outlineLevel, nil)
+ assert_raise(ArgumentError, 'outline level cannot be negative') { @col.outlineLevel = -1 }
+ assert_raise(ArgumentError, 'outline level cannot be greater than 7') { @col.outlineLevel = 8 }
+ assert_nothing_raised('can set outlineLevel') { @col.outlineLevel = 1 }
+ end
+
+ def test_phonetic
+ assert_equal(@col.phonetic, nil)
+ assert_raise(ArgumentError, 'phonetic must be boolean(ish)') { @col.phonetic = 'bob' }
+ assert_nothing_raised(ArgumentError, 'phonetic must be boolean(ish)') { @col.phonetic = true }
+ end
+
+ def test_style
+ assert_equal(@col.style, nil)
+ #TODO check that the style specified is actually in the styles xfs collection
+ end
+
+end