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.45 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.44 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.43 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.42 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.41 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.40 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.39 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.38 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.37 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.36 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.35 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.34 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.33 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.32 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.31 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.30 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.29 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.28 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.27 test/models/workarea/navigation/breadcrumbs_test.rb
workarea-core-3.4.26 test/models/workarea/navigation/breadcrumbs_test.rb