diff options
| author | Randy Morgan <[email protected]> | 2012-12-04 09:55:27 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-12-04 09:55:27 +0900 |
| commit | 66e1cc2178f78ee225642080b40b9a7811d92b8a (patch) | |
| tree | 294a15978e2beab8ada28589fd1072b6af26ee57 /test/workbook/worksheet/tc_sheet_format_pr.rb | |
| parent | 265f30d9e827d7cfb8721c315c284de52e7395e5 (diff) | |
| download | caxlsx-66e1cc2178f78ee225642080b40b9a7811d92b8a.tar.gz caxlsx-66e1cc2178f78ee225642080b40b9a7811d92b8a.zip | |
Added sheet_format_pr to help iOS/OSX preview renderers look nice
This is part of https://github.com/randym/axlsx/issues/149
Diffstat (limited to 'test/workbook/worksheet/tc_sheet_format_pr.rb')
| -rw-r--r-- | test/workbook/worksheet/tc_sheet_format_pr.rb | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_sheet_format_pr.rb b/test/workbook/worksheet/tc_sheet_format_pr.rb new file mode 100644 index 00000000..0f3a7703 --- /dev/null +++ b/test/workbook/worksheet/tc_sheet_format_pr.rb @@ -0,0 +1,79 @@ +require 'tc_helper.rb' + +class TestSheetFormatPr < Test::Unit::TestCase + + def setup + @options = { + :base_col_width => 5, + :default_col_width => 7.2, + :default_row_height => 5.2, + :custom_height => true, + :zero_height => false, + :thick_top => true, + :thick_bottom => true, + :outline_level_row => 0, + :outline_level_col => 0 + } + @sheet_format_pr = Axlsx::SheetFormatPr.new(@options) + end + + def test_default_initialization + sheet_format_pr = Axlsx::SheetFormatPr.new + assert_equal 8, sheet_format_pr.base_col_width + assert_equal 18, sheet_format_pr.default_row_height + end + + def test_initialization_with_options + @options.each do |key, value| + assert_equal value, @sheet_format_pr.instance_variable_get("@#{key}") + end + end + + def test_base_col_width + assert_raise(ArgumentError) { @sheet_format_pr.base_col_width = :foo } + assert_nothing_raised { @sheet_format_pr.base_col_width = 1 } + end + + def test_outline_level_row + assert_raise(ArgumentError) { @sheet_format_pr.outline_level_row = :foo } + assert_nothing_raised { @sheet_format_pr.outline_level_row = 1 } + end + + def test_outline_level_col + assert_raise(ArgumentError) { @sheet_format_pr.outline_level_col = :foo } + assert_nothing_raised { @sheet_format_pr.outline_level_col = 1 } + end + + def test_default_row_height + assert_raise(ArgumentError) { @sheet_format_pr.default_row_height = :foo } + assert_nothing_raised { @sheet_format_pr.default_row_height= 1.0 } + end + + def test_default_col_width + assert_raise(ArgumentError) { @sheet_format_pr.default_col_width= :foo } + assert_nothing_raised { @sheet_format_pr.default_col_width = 1.0 } + end + + def test_custom_height + assert_raise(ArgumentError) { @sheet_format_pr.custom_height= :foo } + assert_nothing_raised { @sheet_format_pr.custom_height = true } + end + + def test_zero_height + assert_raise(ArgumentError) { @sheet_format_pr.zero_height= :foo } + assert_nothing_raised { @sheet_format_pr.zero_height = true } + end + def test_thick_top + assert_raise(ArgumentError) { @sheet_format_pr.thick_top= :foo } + assert_nothing_raised { @sheet_format_pr.thick_top = true } + end + def test_thick_bottom + assert_raise(ArgumentError) { @sheet_format_pr.thick_bottom= :foo } + assert_nothing_raised { @sheet_format_pr.thick_bottom = true } + end + def test_to_xml_string + doc = Nokogiri::XML(@sheet_format_pr.to_xml_string) + assert doc.xpath("sheetFormatPr[@thickBottom='true']") + end + +end |
