|
| 1 | +require 'rails_helper' |
| 2 | + |
| 3 | +RSpec.describe InitiativeHeaderPresenter do |
| 4 | + let(:view_context) { double('view_context', state_initiative_path: '/initiatives/1/state', initiative_breadcrumb: '<nav>breadcrumb</nav>') } |
| 5 | + |
| 6 | + describe 'with nil entity' do |
| 7 | + subject(:presenter) { described_class.new(entity: nil, view_context: view_context) } |
| 8 | + |
| 9 | + it 'returns default name' do |
| 10 | + expect(presenter.name).to eq('Initiative') |
| 11 | + end |
| 12 | + |
| 13 | + it 'returns nil description' do |
| 14 | + expect(presenter.description).to be_nil |
| 15 | + end |
| 16 | + |
| 17 | + it 'returns nil point_of_contact' do |
| 18 | + expect(presenter.point_of_contact).to be_nil |
| 19 | + end |
| 20 | + |
| 21 | + it 'returns false for archived?' do |
| 22 | + expect(presenter.archived?).to be false |
| 23 | + end |
| 24 | + |
| 25 | + it 'returns nil current_state' do |
| 26 | + expect(presenter.current_state).to be_nil |
| 27 | + end |
| 28 | + |
| 29 | + it 'returns nil state_path' do |
| 30 | + expect(presenter.state_path).to be_nil |
| 31 | + end |
| 32 | + |
| 33 | + it 'returns empty breadcrumb' do |
| 34 | + expect(presenter.breadcrumb).to eq([]) |
| 35 | + end |
| 36 | + end |
| 37 | + |
| 38 | + describe 'with valid entity' do |
| 39 | + let(:entity) do |
| 40 | + double('Initiative', |
| 41 | + name: 'Q1 Launch', |
| 42 | + description: 'Launch new product', |
| 43 | + point_of_contact: 'pm@example.com', |
| 44 | + archived?: false, |
| 45 | + current_state: :in_progress, |
| 46 | + id: '1' |
| 47 | + ) |
| 48 | + end |
| 49 | + subject(:presenter) { described_class.new(entity: entity, view_context: view_context) } |
| 50 | + |
| 51 | + it 'returns entity name' do |
| 52 | + expect(presenter.name).to eq('Q1 Launch') |
| 53 | + end |
| 54 | + |
| 55 | + it 'returns entity description' do |
| 56 | + expect(presenter.description).to eq('Launch new product') |
| 57 | + end |
| 58 | + |
| 59 | + it 'returns entity point_of_contact' do |
| 60 | + expect(presenter.point_of_contact).to eq('pm@example.com') |
| 61 | + end |
| 62 | + |
| 63 | + it 'returns entity archived?' do |
| 64 | + expect(presenter.archived?).to be false |
| 65 | + end |
| 66 | + |
| 67 | + it 'returns entity current_state' do |
| 68 | + expect(presenter.current_state).to eq(:in_progress) |
| 69 | + end |
| 70 | + |
| 71 | + it 'returns state_path' do |
| 72 | + expect(presenter.state_path).to eq('/initiatives/1/state') |
| 73 | + end |
| 74 | + |
| 75 | + it 'returns breadcrumb' do |
| 76 | + expect(presenter.breadcrumb).to eq('<nav>breadcrumb</nav>') |
| 77 | + end |
| 78 | + end |
| 79 | +end |
0 commit comments