Sha256: 53e387cc22d8ce4b027d4233057917fc29b4b5a05d7b86eb3d390d5704f9cca3

Contents?: true

Size: 912 Bytes

Versions: 1

Compression:

Stored size: 912 Bytes

Contents

require "test_helper"

class MoreTest < Minitest::Test
  setup do
    Paginate.configure do |config|
      config.param_name = :page
      config.size  = 10
    end

    I18n.locale = :en

    @renderer = Paginate::Renderer::More.new(nil, {
      collection: Array.new(11),
      page: 1,
      fullpath: "/some/path"
    })
  end

  test "returns safe html" do
    assert @renderer.render.html_safe?
  end

  test "returns label" do
    assert_equal I18n.t("paginate.more"), @renderer.more_label
  end

  test "returns nothing when have no next page" do
    @renderer.processor.stubs(next_page?: false)
    assert_nil @renderer.render
  end

  test "returns html when have next page" do
    html = Nokogiri::HTML(@renderer.render)
    selector = "p.paginate > a.more"

    assert_equal @renderer.more_label, html.css(selector).text
    assert_equal @renderer.next_url, html.css(selector).first[:href]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paginate-4.0.1 test/paginate/renderer/more_test.rb