# frozen_string_literal: true require "excerpt_parser" RSpec.describe ExcerptParser do it "handles nested
blocks" do html = <<~HTML.strip
FOO
BAR

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

HTML expect(ExcerptParser.get_excerpt(html, 50, {})).to match_html "▶ FOO" expect(ExcerptParser.get_excerpt(html, 6, {})).to match_html "▶ FOO" expect(ExcerptParser.get_excerpt(html, 3, {})).to match_html "▶ FOO" expect(ExcerptParser.get_excerpt(html, 2, {})).to match_html "▶ FO…" end it "allows with inside for icons when keep_svg is true" do html = '' expect(ExcerptParser.get_excerpt(html, 100, { keep_svg: true })).to match_html( '', ) expect(ExcerptParser.get_excerpt(html, 100, {})).to match_html("") html = '' expect(ExcerptParser.get_excerpt(html, 100, { keep_svg: true })).to match_html("") html = '' expect(ExcerptParser.get_excerpt(html, 100, { keep_svg: true })).to match_html("") html = '' expect(ExcerptParser.get_excerpt(html, 100, { keep_svg: true })).to match_html( '', ) end describe "keep_onebox_body parameter" do it "keeps the body content for external oneboxes" do html = <<~HTML.strip GitHub

discourse/discourse

A platform for community discussion. Free, open, simple. - discourse/discourse

HTML expect(ExcerptParser.get_excerpt(html, 100, keep_onebox_body: true)).to eq(<<~HTML.strip) [image] discourse/discourse A platform for community discussion. Free, o… HTML end it "keeps the content for internal oneboxes" do html = <<~HTML.strip HTML expect(ExcerptParser.get_excerpt(html, 100, keep_onebox_body: true)).to eq(<<~HTML.strip) [image] Welcome to Discourse The first paragraph of this pinned topic will be … HTML end it "keeps the content for internal oneboxes that contain github oneboxes" do html = <<~HTML.strip

Another commit to test out.

This time this commit has a longer commit message.

HTML expect(ExcerptParser.get_excerpt(html, 100, keep_onebox_body: false)).to eq(<<~HTML.strip) Another commit to test out. \nThis time this commit has a longer commit message. HTML end end describe "keep_quotes parameter" do it "should keep the quoted content in html" do html = <<~HTML.strip HTML expect(ExcerptParser.get_excerpt(html, 100, keep_quotes: true)).to eq( "This is a quoted text.", ) end end end