1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# frozen_string_literal: true
require 'tc_helper'
class TestSheetPr < Test::Unit::TestCase
def setup
worksheet = Axlsx::Package.new.workbook.add_worksheet
@options = {
sync_horizontal: false,
sync_vertical: false,
transition_evaluation: true,
transition_entry: true,
published: false,
filter_mode: true,
enable_format_conditions_calculation: false,
code_name: '007',
sync_ref: 'foo',
tab_color: 'FFFF6666'
}
@sheet_pr = Axlsx::SheetPr.new(worksheet, @options)
end
def test_initialization
@options.each do |key, value|
if key == :tab_color
stored_value = @sheet_pr.send(key)
assert_instance_of Axlsx::Color, stored_value
assert_equal value, stored_value.rgb
else
assert_equal value, @sheet_pr.send(key)
end
end
end
def test_to_xml_string
doc = Nokogiri::XML(@sheet_pr.to_xml_string)
assert_equal(1, doc.xpath("//sheetPr[@syncHorizontal='0']").size)
assert_equal(1, doc.xpath("//sheetPr[@syncVertical='0']").size)
assert_equal(1, doc.xpath("//sheetPr[@transitionEvaluation='1']").size)
assert_equal(1, doc.xpath("//sheetPr[@transitionEntry='1']").size)
assert_equal(1, doc.xpath("//sheetPr[@published='0']").size)
assert_equal(1, doc.xpath("//sheetPr[@filterMode='1']").size)
assert_equal(1, doc.xpath("//sheetPr[@enableFormatConditionsCalculation='0']").size)
assert_equal(1, doc.xpath("//sheetPr[@codeName='007']").size)
assert_equal(1, doc.xpath("//sheetPr[@syncRef='foo']").size)
assert_equal(1, doc.xpath("//sheetPr/tabColor[@rgb='FFFF6666']").size)
assert_equal(1, doc.xpath("//sheetPr/pageSetUpPr[@fitToPage='0']").size)
end
end
|