Skip to content

Commit

Permalink
Add tests for defendant presenters
Browse files Browse the repository at this point in the history
  • Loading branch information
jrmhaig committed Apr 2, 2024
1 parent 41523eb commit 876d141
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/presenters/case_workers/defendant_presenter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
RSpec.describe CaseWorkers::DefendantPresenter do
subject(:defendant_presenter) { described_class.new(defendant, view) }

describe '#representation_orders' do
subject(:representation_orders) { defendant_presenter.representation_orders }

context 'when there are representation orders' do
let(:defendant) { build(:defendant, representation_orders: build_list(:representation_order, 3)) }

it { expect(representation_orders.length).to eq 3 }
it { is_expected.to all(be_a(CaseWorkers::RepresentationOrder)) }
end

context 'when there are no representation orders' do
let(:defendant) { build(:defendant, representation_orders: []) }

it { is_expected.to be_empty }
end
end
end
20 changes: 20 additions & 0 deletions spec/presenters/external_users/defendant_presenter_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
RSpec.describe ExternalUsers::DefendantPresenter do
subject(:defendant_presenter) { described_class.new(defendant, view) }

describe '#representation_orders' do
subject(:representation_orders) { defendant_presenter.representation_orders }

context 'when there are representation orders' do
let(:defendant) { build(:defendant, representation_orders: build_list(:representation_order, 3)) }

it { expect(representation_orders.length).to eq 3 }
it { is_expected.to all(be_a(ExternalUsers::RepresentationOrder)) }
end

context 'when there are no representation orders' do
let(:defendant) { build(:defendant, representation_orders: []) }

it { is_expected.to be_empty }
end
end
end

0 comments on commit 876d141

Please sign in to comment.