summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorWeston Ganger <[email protected]>2022-02-05 15:39:05 -0800
committerGitHub <[email protected]>2022-02-06 00:39:05 +0100
commit196862524f94c58b1521ef84a6cf0397b411a685 (patch)
tree43903550e4eca508449f48026e9429474d2e75ad /test
parentd3cf7bca5728b166c7643ad839efeba60ed0e256 (diff)
downloadcaxlsx-196862524f94c58b1521ef84a6cf0397b411a685.tar.gz
caxlsx-196862524f94c58b1521ef84a6cf0397b411a685.zip
Allow border style to accept an Array (#117)
Co-authored-by: Noel Peden <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/stylesheet/tc_styles.rb48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/stylesheet/tc_styles.rb b/test/stylesheet/tc_styles.rb
index 72bf1466..c46b6bdb 100644
--- a/test/stylesheet/tc_styles.rb
+++ b/test/stylesheet/tc_styles.rb
@@ -17,6 +17,7 @@ class TestStyles < Test::Unit::TestCase
end
assert(errors.size == 0)
end
+
def test_add_style_border_hash
border_count = @styles.borders.size
@styles.add_style :border => {:style => :thin, :color => "FFFF0000"}
@@ -26,6 +27,32 @@ class TestStyles < Test::Unit::TestCase
assert_equal @styles.borders.last.prs.size, 4
end
+ def test_add_style_border_array
+ prev_border_count = @styles.borders.size
+
+ borders_array = [
+ {:style => :thin, :color => "DDDDDD"},
+ {:edges => [:top], :style => :thin, :color => "000000"},
+ {:edges => [:bottom], :style => :thick, :color => "FF0000"},
+ {:edges => [:left], :style => :dotted, :color => "FFFF00"},
+ {:edges => [:right], :style => :dashed, :color => "FFFFFF"},
+ {:style => :thick, :color => "CCCCCC"},
+ ]
+
+ @styles.add_style(border: borders_array)
+
+ assert_equal(@styles.borders.size, (prev_border_count+1))
+
+ current_border = @styles.borders.last
+
+ borders_array.each do |b_opts|
+ if b_opts[:edges]
+ border_pr = current_border.prs.detect{|x| x.name == b_opts[:edges].first }
+ assert_equal(border_pr.color.rgb, "FF#{b_opts[:color]}")
+ end
+ end
+ end
+
def test_add_style_border_edges
@styles.add_style :border => { :style => :thin, :color => "0000FFFF", :edges => [:top, :bottom] }
parts = @styles.borders.last.prs
@@ -258,4 +285,25 @@ class TestStyles < Test::Unit::TestCase
end
assert(errors.size == 0)
end
+
+ def test_border_top_without_border_regression
+ ### https://github.com/axlsx-styler-gem/axlsx_styler/issues/31
+
+ borders = {
+ top: { style: :double, color: '0000FF' },
+ right: { style: :thick, color: 'FF0000' },
+ bottom: { style: :double, color: '0000FF' },
+ left: { style: :thick, color: 'FF0000' }
+ }
+
+ borders.each do |edge, b_opts|
+ @styles.add_style("border_#{edge}".to_sym => b_opts)
+
+ current_border = @styles.borders.last
+
+ border_pr = current_border.prs.detect{|x| x.name == edge }
+ assert_equal(border_pr.color.rgb, "FF#{b_opts[:color]}")
+ end
+
+ end
end