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