diff options
| author | Randy Morgan <[email protected]> | 2012-05-13 11:09:12 +0900 |
|---|---|---|
| committer | Randy Morgan <[email protected]> | 2012-05-13 11:09:12 +0900 |
| commit | 34f63d6719fd913be9251f367370947303f8fc61 (patch) | |
| tree | ebe3531eaf04838533cb0dbf18c4ea1844b27925 /test/workbook/worksheet/tc_comments.rb | |
| parent | 88b67ba036c038be9d2cb116bb70eac720f3e40b (diff) | |
| download | caxlsx-34f63d6719fd913be9251f367370947303f8fc61.tar.gz caxlsx-34f63d6719fd913be9251f367370947303f8fc61.zip | |
cleaning up comments for pre-release
Diffstat (limited to 'test/workbook/worksheet/tc_comments.rb')
| -rw-r--r-- | test/workbook/worksheet/tc_comments.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_comments.rb b/test/workbook/worksheet/tc_comments.rb new file mode 100644 index 00000000..cbc267ad --- /dev/null +++ b/test/workbook/worksheet/tc_comments.rb @@ -0,0 +1,50 @@ +require 'tc_helper.rb' + +class TestComments < Test::Unit::TestCase + def setup + p = Axlsx::Package.new + wb = p.workbook + @ws = wb.add_worksheet + @c1 = @ws.add_comment :ref => 'A1', :text => 'penut machine', :author => 'crank' + @c2 = @ws.add_comment :ref => 'C3', :text => 'rust bucket', :author => 'PO' + end + + def test_initialize + assert_raise(ArgumentError) { Axlsx::Comments.new } + assert(@ws.comments.vml_drawing.is_a?(Axlsx::VmlDrawing)) + end + + def test_add_comment + assert_equal(@ws.comments.size, 2) + assert_raise(ArgumentError) { @ws.comments.add_comment() } + assert_raise(ArgumentError) { @ws.comments.add_comment(:text => 'Yes We Can', :ref => 'A1') } + assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :ref => 'A1') } + assert_raise(ArgumentError) { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can')} + assert_nothing_raised { @ws.comments.add_comment(:author => 'bob', :text => 'Yes We Can', :ref => 'A1') } + assert_equal(@ws.comments.size, 3) + end + def test_authors + assert_equal(@ws.comments.authors.size, @ws.comments.size) + @ws.add_comment(:text => 'Yes We Can!', :author => :bob, :ref => 'F1') + assert_equal(@ws.comments.authors.size, 3) + @ws.add_comment(:text => 'Yes We Can!', :author => :bob, :ref => 'F1') + assert_equal(@ws.comments.authors.size, 3, 'only unique authors are returned') + end + def test_pn + assert_equal(@ws.comments.pn, Axlsx::COMMENT_PN % (@ws.index+1).to_s) + end + + def test_index + assert_equal(@ws.index, @ws.comments.index) + end + def test_to_xml_string + doc = Nokogiri::XML(@ws.comments.to_xml_string) + # puts doc.xpath("comments").to_xml + # TODO figure out why these xpath expressions dont work! + # assert(doc.xpath("//comments")) + # assert_equal(doc.xpath("//xmlns:author").size, @ws.comments.authors.size) + # assert_equal(doc.xpath("//comment").size, @ws.comments.size) + end +end + + |
