blob: 7f56e9ed0d6e73af8125be034f06535bf87bc471 (
plain)
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
|
# frozen_string_literal: true
require 'tc_helper'
class TestTableStyleElement < Test::Unit::TestCase
def setup
@item = Axlsx::TableStyleElement.new
end
def teardown; end
def test_initialiation
assert_nil(@item.type)
assert_nil(@item.size)
assert_nil(@item.dxfId)
options = { type: :headerRow, size: 10, dxfId: 1 }
tse = Axlsx::TableStyleElement.new options
options.each { |key, value| assert_equal(tse.send(key.to_sym), value) }
end
def test_type
assert_raise(ArgumentError) { @item.type = -1.1 }
assert_nothing_raised { @item.type = :blankRow }
assert_equal(:blankRow, @item.type)
end
def test_size
assert_raise(ArgumentError) { @item.size = -1.1 }
assert_nothing_raised { @item.size = 2 }
assert_equal(2, @item.size)
end
def test_dxfId
assert_raise(ArgumentError) { @item.dxfId = -1.1 }
assert_nothing_raised { @item.dxfId = 7 }
assert_equal(7, @item.dxfId)
end
def test_to_xml_string
doc = Nokogiri::XML(@item.to_xml_string)
@item.type = :headerRow
assert(doc.xpath("//tableStyleElement[@type='#{@item.type}']"))
end
end
|