Sha256: 8d8bcdcbbb85be4fd0261e7d6c56905c64ebd0355757a3fcdf0aa2e8b76e5e1a

Contents?: true

Size: 1.41 KB

Versions: 4

Compression:

Stored size: 1.41 KB

Contents

require 'jekyll_search/html_processor'

RSpec.describe JekyllSearch::HtmlProcessor do
  it 'stripes html' do
    expect(JekyllSearch::HtmlProcessor.strip_html('test')).to eq 'test'
    expect(JekyllSearch::HtmlProcessor.strip_html("<h1>title</h1>\n<p>text</p>")).to eq 'title text'
  end

  it 'detects sections' do
    expect(JekyllSearch::HtmlProcessor.detect_sections('test')).to eq [
        { :id => nil, :title => nil, :content => 'test' }
    ]
  end

  it 'detects sections' do
    expect(JekyllSearch::HtmlProcessor.detect_sections('<h1>foo</h1>test')).to eq [
        { :id => nil, :title => nil, :content => '' },
        { :id => nil, :title => 'foo', :content => 'test' }
    ]
  end

  it 'detects sections' do
    expect(JekyllSearch::HtmlProcessor.detect_sections("foo<h1>first</h1>bar <p>\npara\n</p>\n\n<H4 ID=\"sec\">sec<span>ond</span></H4>apple<h2>third</h2>")).to eq [
        { :id => nil, :title => nil, :content => "foo" },
        { :id => nil, :title => 'first', :content => "bar <p>\npara\n</p>\n\n" },
        { :id => 'sec', :title => 'second', :content => "apple" },
        { :id => nil, :title => 'third', :content => '' }
    ]
  end

  it 'detects sections' do
    expect(JekyllSearch::HtmlProcessor.detect_sections("<h1>foo<div id=\"inner-id\"></div></h1>bar")).to eq [
        { :id => nil, :title => nil, :content => '' },
        { :id => 'inner-id', :title => 'foo', :content => 'bar' }
    ]
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
jekyll_search-0.0.8 spec/lib/jekyll_search/html_processor_spec.rb
jekyll_search-0.0.7 spec/lib/jekyll_search/html_processor_spec.rb
jekyll_search-0.0.6 spec/lib/jekyll_search/html_processor_spec.rb
jekyll_search-0.0.5 spec/lib/jekyll_search/html_processor_spec.rb