summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Allen <dan.j.allen@gmail.com>2023-04-08 23:58:12 -0600
committerDan Allen <dan.j.allen@gmail.com>2023-04-09 01:28:21 -0600
commitc98422f9bd642dbca411985ffebb231aeade2da4 (patch)
treed3deb1f32cf3a48ce752c031747a93b051e84134 /test
parent2fd7523bd7631a3f5d343f50c44b108e11b81eb5 (diff)
change Block#content to return empty string instead of nil if raw or verbatim block has no lines
* makes return value type consistent
Diffstat (limited to 'test')
-rw-r--r--test/blocks_test.rb30
1 files changed, 21 insertions, 9 deletions
diff --git a/test/blocks_test.rb b/test/blocks_test.rb
index ccb15e1e..ba6182f7 100644
--- a/test/blocks_test.rb
+++ b/test/blocks_test.rb
@@ -1105,14 +1105,19 @@ context 'Blocks' do
assert_message @logger, :WARN, '<stdin>: line 3: unterminated listing block', Hash
end
- test 'should not crash if listing block has no lines' do
- input = <<~'EOS'
- ----
- ----
- EOS
- output = convert_string_to_embedded input
- assert_css 'pre', output, 1
- assert_css 'pre:empty', output, 1
+ test 'should not crash when converting verbatim block that has no lines' do
+ [%(----\n----), %(....\n....)].each do |input|
+ output = convert_string_to_embedded input
+ assert_css 'pre', output, 1
+ assert_css 'pre:empty', output, 1
+ end
+ end
+
+ test 'should return content as empty string for verbatim or raw block that has no lines' do
+ [%(----\n----), %(....\n....)].each do |input|
+ doc = document_from_string input
+ assert_equal '', doc.blocks[0].content
+ end
end
test 'should preserve newlines in literal block' do
@@ -1848,7 +1853,7 @@ context 'Blocks' do
end
context 'Math blocks' do
- test 'should not crash when converting to HTML if stem block is empty' do
+ test 'should not crash when converting stem block that has no lines' do
input = <<~'EOS'
[stem]
++++
@@ -1859,6 +1864,13 @@ context 'Blocks' do
assert_css '.stemblock', output, 1
end
+ test 'should return content as empty string for stem or pass block that has no lines' do
+ [%(++++\n++++), %([stem]\n++++\n++++)].each do |input|
+ doc = document_from_string input
+ assert_equal '', doc.blocks[0].content
+ end
+ end
+
test 'should add LaTeX math delimiters around latexmath block content' do
input = <<~'EOS'
[latexmath]