Sha256: aa013d79e104016bfd7a8d05cd47d083afdca47f1971e4b8d40cc1d551f036c9

Contents?: true

Size: 1.54 KB

Versions: 34

Compression:

Stored size: 1.54 KB

Contents

require 'test_helper'

module Workarea
  module Navigation
    class BreadcrumbsTest < Workarea::TestCase
      setup do
        @navigable = Content::Page.new(name: 'Test Taxon', slug: 'test-link')
        @first = create_taxon(name: 'First')
        @second = create_taxon(name: 'Second', parent: @first, navigable: @navigable)
      end

      def test_global_id
        navigable = create_page
        via = Breadcrumbs.new(navigable).to_global_id

        result = Breadcrumbs.from_global_id(via)
        assert_equal(navigable, result.navigable)
      end

      def test_collection
        breadcrumbs = Breadcrumbs.new(@navigable)
        assert_equal(3, breadcrumbs.length) # including home
      end

      def test_last
        breadcrumbs = Breadcrumbs.new(@navigable, last: 'Test Taxon')
        assert(breadcrumbs.last.is_a?(Navigation::Taxon))
        assert_equal(4, breadcrumbs.length) # including home
        assert_equal('Test Taxon', breadcrumbs.last.name)
      end

      def test_selected
        breadcrumbs = Breadcrumbs.new(@navigable)

        refute(breadcrumbs.selected?(create_taxon))
        assert(breadcrumbs.selected?(@second))
        assert(breadcrumbs.selected?(@first))
      end

      def test_join
        breadcrumbs = Breadcrumbs.new(@navigable)
        assert_equal('Home > First > Second', breadcrumbs.join(' > '))
      end

      def test_presence
        assert(Breadcrumbs.new(nil).blank?)
        assert(Breadcrumbs.new(create_page).blank?)
        assert(Breadcrumbs.new(@navigable).present?)
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-core-3.4.25 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.24 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.23 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.22 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.21 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.20 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.19 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.18 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.17 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.16 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.15 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.14 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.13 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.12 test/models/workarea/navigation/breadcrumbs_test.rb