Commit 880a233e6d1bcf0dbeb9d1a01fb816b77ed21cc9
1 parent
d480a478
Exists in
master
and in
4 other branches
Add specs for parsing Emoji
Showing
1 changed file
with
34 additions
and
0 deletions
Show diff stats
spec/helpers/gitlab_markdown_helper_spec.rb
| ... | ... | @@ -208,6 +208,40 @@ describe GitlabMarkdownHelper do |
| 208 | 208 | gfm(actual).should match(expected) |
| 209 | 209 | end |
| 210 | 210 | end |
| 211 | + | |
| 212 | + describe "emoji" do | |
| 213 | + it "matches at the start of a string" do | |
| 214 | + gfm(":+1:").should match(/<img/) | |
| 215 | + end | |
| 216 | + | |
| 217 | + it "matches at the end of a string" do | |
| 218 | + gfm("This gets a :-1:").should match(/<img/) | |
| 219 | + end | |
| 220 | + | |
| 221 | + it "matches with adjacent text" do | |
| 222 | + gfm("+1 (:+1:)").should match(/<img/) | |
| 223 | + end | |
| 224 | + | |
| 225 | + it "has a title attribute" do | |
| 226 | + gfm(":-1:").should match(/title=":-1:"/) | |
| 227 | + end | |
| 228 | + | |
| 229 | + it "has an alt attribute" do | |
| 230 | + gfm(":-1:").should match(/alt=":-1:"/) | |
| 231 | + end | |
| 232 | + | |
| 233 | + it "has an emoji class" do | |
| 234 | + gfm(":+1:").should match('class="emoji"') | |
| 235 | + end | |
| 236 | + | |
| 237 | + it "keeps whitespace intact" do | |
| 238 | + gfm("This deserves a :+1: big time.").should match(/deserves a <img.+\/> big time/) | |
| 239 | + end | |
| 240 | + | |
| 241 | + it "ignores invalid emoji" do | |
| 242 | + gfm(":invalid-emoji:").should_not match(/<img/) | |
| 243 | + end | |
| 244 | + end | |
| 211 | 245 | end |
| 212 | 246 | |
| 213 | 247 | describe "#link_to_gfm" do | ... | ... |