Sha256: 913a06062af7534f991a7d562c6d9c318ca04c38b72f609e438dbe3f46961d93

Contents?: true

Size: 1.35 KB

Versions: 12

Compression:

Stored size: 1.35 KB

Contents

require 'test_helper'

module Kadmin
  module Navbar
    class Section
      class PresenterTest < Kadmin::Presenter::TestCase
        def setup
          @links = [
            flexmock(Kadmin::Navbar::Link.new(text: 'link1', path: 'path1')),
            flexmock(Kadmin::Navbar::Link.new(text: 'link2', path: 'path2'))
          ]

          @links.each do |link|
            link.should_receive(:present).and_return(link)
            link.should_receive(:render).and_return('')
          end
          @section = Kadmin::Navbar::Section.new(id: 'Section', text: 'text', links: @links, css_classes: %w(icon plus))
        end

        def test_render
          present @section
          assert_select 'li.icon.plus > a', count: 1, text: 'text'
          assert_select 'li.icon.plus > ul', count: 1

          @links.each do |link|
            assert_spy_called link, { times: 1 }, :present, self
            assert_spy_called link, { times: 1 }, :render
          end
        end

        def test_render_open
          # fake section to be current one
          self.controller.class.class_exec do
            class << self
              attr_reader :navbar_section
            end
            @navbar_section = 'Section'
          end

          present @section
          assert_select 'li.active.open.icon.plus', count: 1, text: 'text'
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
kadmin-0.6.8 test/components/navbar/section_test.rb
kadmin-0.6.7 test/components/navbar/section_test.rb
kadmin-0.6.6 test/components/navbar/section_test.rb
kadmin-0.6.5 test/components/navbar/section_test.rb
kadmin-0.6.4 test/components/navbar/section_test.rb
kadmin-0.6.3 test/components/navbar/section_test.rb
kadmin-0.6.1 test/components/navbar/section_test.rb
kadmin-0.5.7 test/components/navbar/section_test.rb
kadmin-0.5.6 test/components/navbar/section_test.rb
kadmin-0.4.2 test/components/navbar/section_test.rb
kadmin-0.4.1 test/components/navbar/section_test.rb
kadmin-0.4.0 test/components/navbar/section_test.rb