summaryrefslogtreecommitdiffhomepage
path: root/test/stylesheet/tc_xf.rb
blob: b678ce153f5e56528837fa0c7f48df9a7969b38e (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# frozen_string_literal: true

require 'tc_helper'

class TestXf < Test::Unit::TestCase
  def setup
    @item = Axlsx::Xf.new
  end

  def teardown; end

  def test_initialiation
    assert_nil(@item.alignment)
    assert_nil(@item.protection)
    assert_nil(@item.numFmtId)
    assert_nil(@item.fontId)
    assert_nil(@item.fillId)
    assert_nil(@item.borderId)
    assert_nil(@item.xfId)
    assert_nil(@item.quotePrefix)
    assert_nil(@item.pivotButton)
    assert_nil(@item.applyNumberFormat)
    assert_nil(@item.applyFont)
    assert_nil(@item.applyFill)
    assert_nil(@item.applyBorder)
    assert_nil(@item.applyAlignment)
    assert_nil(@item.applyProtection)
  end

  def test_alignment
    assert_raise(ArgumentError) { @item.alignment = -1.1 }
    assert_nothing_raised { @item.alignment = Axlsx::CellAlignment.new }
    assert(@item.alignment.is_a?(Axlsx::CellAlignment))
  end

  def test_protection
    assert_raise(ArgumentError) { @item.protection = -1.1 }
    assert_nothing_raised { @item.protection = Axlsx::CellProtection.new }
    assert(@item.protection.is_a?(Axlsx::CellProtection))
  end

  def test_numFmtId
    assert_raise(ArgumentError) { @item.numFmtId = -1.1 }
    assert_nothing_raised { @item.numFmtId = 0 }
    assert_equal(0, @item.numFmtId)
  end

  def test_fillId
    assert_raise(ArgumentError) { @item.fillId = -1.1 }
    assert_nothing_raised { @item.fillId = 0 }
    assert_equal(0, @item.fillId)
  end

  def test_fontId
    assert_raise(ArgumentError) { @item.fontId = -1.1 }
    assert_nothing_raised { @item.fontId = 0 }
    assert_equal(0, @item.fontId)
  end

  def test_borderId
    assert_raise(ArgumentError) { @item.borderId = -1.1 }
    assert_nothing_raised { @item.borderId = 0 }
    assert_equal(0, @item.borderId)
  end

  def test_xfId
    assert_raise(ArgumentError) { @item.xfId = -1.1 }
    assert_nothing_raised { @item.xfId = 0 }
    assert_equal(0, @item.xfId)
  end

  def test_quotePrefix
    assert_raise(ArgumentError) { @item.quotePrefix = -1.1 }
    assert_nothing_raised { @item.quotePrefix = false }
    refute(@item.quotePrefix)
  end

  def test_pivotButton
    assert_raise(ArgumentError) { @item.pivotButton = -1.1 }
    assert_nothing_raised { @item.pivotButton = false }
    refute(@item.pivotButton)
  end

  def test_applyNumberFormat
    assert_raise(ArgumentError) { @item.applyNumberFormat = -1.1 }
    assert_nothing_raised { @item.applyNumberFormat = false }
    refute(@item.applyNumberFormat)
  end

  def test_applyFont
    assert_raise(ArgumentError) { @item.applyFont = -1.1 }
    assert_nothing_raised { @item.applyFont = false }
    refute(@item.applyFont)
  end

  def test_applyFill
    assert_raise(ArgumentError) { @item.applyFill = -1.1 }
    assert_nothing_raised { @item.applyFill = false }
    refute(@item.applyFill)
  end

  def test_applyBorder
    assert_raise(ArgumentError) { @item.applyBorder = -1.1 }
    assert_nothing_raised { @item.applyBorder = false }
    refute(@item.applyBorder)
  end

  def test_applyAlignment
    assert_raise(ArgumentError) { @item.applyAlignment = -1.1 }
    assert_nothing_raised { @item.applyAlignment = false }
    refute(@item.applyAlignment)
  end

  def test_applyProtection
    assert_raise(ArgumentError) { @item.applyProtection = -1.1 }
    assert_nothing_raised { @item.applyProtection = false }
    refute(@item.applyProtection)
  end
end