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_comment.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_comment.rb')
| -rw-r--r-- | test/workbook/worksheet/tc_comment.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/workbook/worksheet/tc_comment.rb b/test/workbook/worksheet/tc_comment.rb new file mode 100644 index 00000000..352f30a0 --- /dev/null +++ b/test/workbook/worksheet/tc_comment.rb @@ -0,0 +1,56 @@ +require 'tc_helper.rb' + +class TestComment < 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_initailize + assert_raise(ArgumentError) { Axlsx::Comment.new } + end + + def test_author + assert(@c1.author == 'crank') + assert(@c2.author == 'PO') + end + + def test_text + assert(@c1.text == 'penut machine') + assert(@c2.text == 'rust bucket') + end + + def test_author_index + assert_equal(@c1.author_index, 1) + assert_equal(@c2.author_index, 0) + end + + def test_ref + assert(@c1.ref == 'A1') + assert(@c2.ref == 'C3') + end + + def test_vml_shape + assert(@c1.vml_shape.is_a?(Axlsx::VmlShape)) + assert(@c1.vml_shape.column == Axlsx::name_to_indices(@c1.ref)[0]) + assert(@c1.vml_shape.row == Axlsx::name_to_indices(@c1.ref)[1]) + assert(@c1.vml_shape.row == Axlsx::name_to_indices(@c1.ref)[1]) + assert(@c1.vml_shape.left_column == Axlsx::name_to_indices(@c1.ref)[1]+1) + assert(@c1.vml_shape.top_row == Axlsx::name_to_indices(@c1.ref)[1]) + assert(@c1.vml_shape.right_column == Axlsx::name_to_indices(@c1.ref)[0]+4) + assert(@c1.vml_shape.bottom_row == Axlsx::name_to_indices(@c1.ref)[1]+4) + end + + def to_xml_string + doc = Nokogiri::XML(@c1.to_xml_string) + assert_equal(doc.xpath("//comment[@ref='#{@c1.ref}']").size, 1) + assert_equal(doc.xpath("//comment[@authorId='#{@c1.author_index.to}']").size, 1) + assert_equal(doc.xpath("//t[text()='#{@c1.author}']").size, 1) + assert_equal(doc.xpath("//t[text()='#{@c1.text}']").size, 1) + end + +end + |
