Skip to content

Commit

Permalink
linter fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-mccurdy committed Nov 21, 2024
1 parent e04bf62 commit 8f17c9d
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions modules/vaos/spec/services/v2/appointment_service_old_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -482,24 +482,29 @@

describe '#get_recent_sorted_clinic_appointments' do
subject { instance_of_class.get_recent_sorted_clinic_appointments }

let(:instance_of_class) { described_class.new(user) }
let(:mock_appointment_one) { double('Appointment', kind: 'clinic', start: '2022-12-02') }
let(:mock_appointment_two) { double('Appointment', kind: 'telehealth', start: '2022-12-01T21:38:01.476Z') }
let(:mock_appointment_three) { double('Appointment', kind: 'clinic', start: '2022-12-09T21:38:01.476Z') }

context 'when appointments are available' do
before do
allow(instance_of_class).to receive(:get_appointments).and_return({ data: [mock_appointment_one,
mock_appointment_two,
mock_appointment_three] })
end

it 'returns the recent sorted clinic appointments' do
expect(subject).to eq([mock_appointment_two, mock_appointment_one, mock_appointment_three])
end
end

context 'when no appointments are available' do
before do
allow(instance_of_class).to receive(:get_appointments).and_return({ data: [] })
end

it 'returns nil' do
expect(subject.first).to be_nil
end
Expand All @@ -508,30 +513,36 @@

describe '#sort_recent_appointments' do
subject { instance_of_class }

let(:instance_of_class) { described_class.new(user) }
let(:mock_appointment_one) { double('Appointment', id: '123', kind: 'clinic', start: '2022-12-02') }
let(:mock_appointment_two) do
double('Appointment', id: '124', kind: 'telehealth', start: '2022-12-01T21:38:01.476Z')
end
let(:mock_appointment_three) { double('Appointment', id: '125', kind: 'clinic', start: '2022-12-09T21:38:01.476Z') }
let(:mock_appointment_three) do
double('Appointment', id: '125', kind: 'clinic', start: '2022-12-09T21:38:01.476Z')
end
let(:mock_appointment_four_no_start) { double('Appointment', id: '126', kind: 'clinic', start: nil) }
let(:appointments_input_no_start) do
[mock_appointment_one, mock_appointment_two, mock_appointment_three, mock_appointment_four_no_start]
end
let(:appointments_input) { [mock_appointment_one, mock_appointment_two, mock_appointment_three] }
let(:filtered_sorted_appointments) { [mock_appointment_two, mock_appointment_one, mock_appointment_three] }

context 'when appointments are available' do
it 'sorts based on start time' do
expect(subject.send(:sort_recent_appointments, appointments_input)).to eq(filtered_sorted_appointments)
expect(Rails.logger).not_to receive(:info)
end
end

context 'when appointments are available and at least one is missing a start time' do
it 'filters before sorting and logs removed appointments' do
allow(Rails.logger).to receive(:info)
expect(subject.send(:sort_recent_appointments, appointments_input_no_start)).to eq(filtered_sorted_appointments)
expect(subject.send(:sort_recent_appointments,
appointments_input_no_start)).to eq(filtered_sorted_appointments)
expect(Rails.logger).to have_received(:info)
.with('VAOS appointment sorting filtered out id 126 due to missing start time.')
.with('VAOS appointment sorting filtered out id 126 due to missing start time.')
end
end
end
Expand Down

0 comments on commit 8f17c9d

Please sign in to comment.