# frozen_string_literal: true require_relative "../test_helper" module Parser class TextContentTest < Minitest::Spec include SnapshotUtils test "text content" do assert_parsed_snapshot("Hello World") end test "text content inside tag" do assert_parsed_snapshot("
<%= hello %> !
") end test "multiple non-breaking spaces in text" do assert_parsed_snapshot("Hello World
") end test "non-breaking space in attribute value" do assert_parsed_snapshot('Did we get it wrong? Respond with @reverse to remove the receipt.
") end test "at symbol at beginning of text" do assert_parsed_snapshot("@username") end test "multiple at symbols in text" do assert_parsed_snapshot("Email me @john@example.com
") end test "at symbol mixed with ERB" do assert_parsed_snapshot("Contact <%= user.name %> @support
") end test "at symbol in attribute value" do assert_parsed_snapshot('Contact @support') end test "backtick with HTML tags - issue 467" do assert_parsed_snapshot("a `` c") end test "backslash-prefixed text stays literal - issue 635" do assert_parsed_snapshot("\\Asome-regexp\\z
") end # https://github.com/lobsters/lobsters/blob/75f9a53077d5aeaeadbb8271def0479dd8fcd761/app/views/domains/edit.html.erb#L11 test "backslash-prefixed text - issue 633" do assert_parsed_snapshot <<~HTMLRegexp with captures, must consume whole string like: \\Ahttps?://github.com/+([^/]+).*\\z
HTML end test "greater than sign as text content - issue 914" do assert_parsed_snapshot(">") end test "greater than sign in text content" do assert_parsed_snapshot("5 > 3
") end test "multiple greater than signs in text content" do assert_parsed_snapshot("a >> b")
end
test "greater than sign at start of text content" do
assert_parsed_snapshot("> quote")
end
test "less than sign as text content" do
assert_parsed_snapshot("<")
end
test "less than sign in text content" do
assert_parsed_snapshot("5 < 3
") end test "multiple less than signs in text content" do assert_parsed_snapshot("<<")
end
test "less than sign at start of text content" do
assert_parsed_snapshot("< quote")
end
test "less than and greater than in text content" do
assert_parsed_snapshot("a < b > c
") end test "arrow in text content" do assert_parsed_snapshot("a -> b") end test "generic syntax in text content" do assert_parsed_snapshot("Array")
end
test "less than followed by space" do
assert_parsed_snapshot("< /span>
") end test "less than followed by number" do assert_parsed_snapshot("<5
") end test "triple less than" do assert_parsed_snapshot("<<<")
end
test "heredoc style" do
assert_parsed_snapshot("<<~HTML")
end
test "bit shift operators" do
assert_parsed_snapshot("x << 2 >> 1")
end
test "spaceship operator" do
assert_parsed_snapshot("a <=> b")
end
test "not equal operator" do
assert_parsed_snapshot("a <> b")
end
test "less than or equal" do
assert_parsed_snapshot("a <= b")
end
test "greater than or equal" do
assert_parsed_snapshot("a >= b")
end
test "xml-like content in code" do
assert_parsed_snapshot("")
end
test "template literal style" do
assert_parsed_snapshot("${value}")
end
end
end