summaryrefslogtreecommitdiffhomepage
path: root/test/workbook/worksheet/tc_worksheet_hyperlink.rb
diff options
context:
space:
mode:
authorRandy Morgan <[email protected]>2012-08-11 15:44:46 +0900
committerRandy Morgan <[email protected]>2012-08-11 15:44:46 +0900
commit0331602d4c0012b13f7bf4950785d8d8d7b1e54a (patch)
tree98188574b1ae62c25a13948c564a5071675408fc /test/workbook/worksheet/tc_worksheet_hyperlink.rb
parentbe69023865bb02c544221d5dba5a189b2774adb2 (diff)
downloadcaxlsx-0331602d4c0012b13f7bf4950785d8d8d7b1e54a.tar.gz
caxlsx-0331602d4c0012b13f7bf4950785d8d8d7b1e54a.zip
add hyperlinks for worksheets #118
Diffstat (limited to 'test/workbook/worksheet/tc_worksheet_hyperlink.rb')
-rw-r--r--test/workbook/worksheet/tc_worksheet_hyperlink.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_worksheet_hyperlink.rb b/test/workbook/worksheet/tc_worksheet_hyperlink.rb
new file mode 100644
index 00000000..f8c6bcff
--- /dev/null
+++ b/test/workbook/worksheet/tc_worksheet_hyperlink.rb
@@ -0,0 +1,45 @@
+require 'tc_helper.rb'
+
+class TestWorksheetHyperlink < Test::Unit::TestCase
+ def setup
+ p = Axlsx::Package.new
+ wb = p.workbook
+ @ws = wb.add_worksheet
+ @options = { :location => 'https://github.com/randym/axlsx', :tooltip => 'axlsx', :ref => 'A1', :display => 'AXSLX', :r_id => 'rId1' }
+ @a = @ws.add_hyperlink @options
+ end
+
+ def test_initailize
+ assert_raise(ArgumentError) { Axlsx::WorksheetHyperlink.new }
+ end
+
+ def test_location
+ assert_equal(@options[:location], @a.location)
+ end
+
+ def test_tooltip
+ assert_equal(@options[:tooltip], @a.tooltip)
+ end
+
+ def test_display
+ assert_equal(@options[:display], @a.display)
+ end
+ def test_ref
+ assert_equal(@options[:ref], @a.ref)
+ end
+ def test_r_id
+ assert_equal("rId1", @a.r_id)
+ end
+
+
+ def test_to_xml_string
+ doc = Nokogiri::XML(@a.to_xml_string)
+ puts doc.to_xml
+ assert_equal(doc.xpath("//hyperlink[@ref='#{@a.ref}']").size, 1)
+ assert_equal(doc.xpath("//hyperlink[@tooltip='#{@a.tooltip}']").size, 1)
+ assert_equal(doc.xpath("//hyperlink[@display='#{@a.display}']").size, 1)
+ assert_equal(doc.xpath("//hyperlink[@location='#{@a.location}']").size, 1)
+ end
+end
+
+