Skip to content

Commit

Permalink
test: appointment unit tests (#122)
Browse files Browse the repository at this point in the history
addons:
- increase size of search input

Signed-off-by: Kathurima Kimathi <[email protected]>
  • Loading branch information
KathurimaKimathi authored Sep 19, 2023
1 parent c38fdb9 commit 24086b8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ public class AppointmentServiceImplTest {

private static MyCareHubSetting setting;

private static final String mflCode = "232343434";

@Before
public void setUp() {
myCareHubSettingsService = mock(MyCareHubSettingsService.class);
Expand All @@ -68,8 +70,10 @@ public void setUp() {
assertNotNull(CURRENT_DATE);

mockStatic(Context.class);
mockStatic(MyCareHubUtil.class);
when(Context.getService(MyCareHubSettingsService.class)).thenReturn(myCareHubSettingsService);
when(Context.getPatientService()).thenReturn(mock(PatientService.class));
when(MyCareHubUtil.getDefaultLocationMflCode()).thenReturn(mflCode);
}

@Test
Expand Down Expand Up @@ -209,28 +213,26 @@ public void syncPatientAppointmentsWithNullRequests() {
fakeAppointmentImpl.syncPatientAppointmentRequests();
}

// @Test
// public void syncPatientAppointmentsEmptyAppointments(){
// when(myCareHubSettingsService.getLatestMyCareHubSettingByType(
// PATIENT_APPOINTMENTS))
// .thenReturn(setting);
//
// Date lastSyncTime = new Date();
// when(setting.getLastSyncTime()).thenReturn(lastSyncTime);
// List<Obs> appointments = new ArrayList<Obs>();
//
// when(appointmentDao.getAppointmentsByLastSyncDate(eq(lastSyncTime))).thenReturn(appointments);
//
// fakeAppointmentImpl.syncPatientAppointments();
// }
@Test
public void syncPatientAppointmentsEmptyAppointments() {
when(myCareHubSettingsService.getLatestMyCareHubSettingByType(PATIENT_APPOINTMENTS))
.thenReturn(setting);

Date lastSyncTime = new Date();
when(setting.getLastSyncTime()).thenReturn(lastSyncTime);
List<Obs> appointments = new ArrayList<Obs>();

when(appointmentDao.getAppointmentsByLastSyncDate(eq(lastSyncTime))).thenReturn(appointments);

fakeAppointmentImpl.syncPatientAppointments();
}

@Test
public void fetchPatientAppointmentRequests_nullSetting() {
when(myCareHubSettingsService.createMyCareHubSetting(
PATIENT_APPOINTMENTS_REQUESTS_GET, CURRENT_DATE))
.thenReturn(null);

// Call the method to test
fakeAppointmentImpl.fetchPatientAppointmentRequests();
}

Expand All @@ -244,7 +246,6 @@ public void fetchPatientAppointmentRequests() {
List<AppointmentRequests> appointmentRequestsList = createAppointmentRequests();
assertNotNull(appointmentRequestsList);

// Call the method to test
fakeAppointmentImpl.fetchPatientAppointmentRequests();
}

Expand Down
2 changes: 1 addition & 1 deletion omod/src/main/webapp/fragments/appointmentRequests.gsp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="ke-panel-frame" ng-controller="AppointmentRequestsCtrl" ng-init="init()">
<div class="ke-panel-heading">Appointment Requests
<input type="text" name="appointmentsSearchString" ng-model="appointmentsSearchString"
ng-change="searchAppointments()" style="width: 300px;margin-left:50px" placeholder="Search using CCC, client name, client contact, appointment reason or status."/>
ng-change="searchAppointments()" style="width: 450px;margin-left:50px" placeholder="Search using CCC, client name, client contact, appointment reason or status."/>
</div>
<div class="ke-panel-content">
<table class="ke-table-vertical">
Expand Down
2 changes: 1 addition & 1 deletion omod/src/main/webapp/fragments/healthDiary.gsp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="ke-panel-frame" ng-controller="HealthDiaryCtrl" ng-init="init()">
<div class="ke-panel-heading">Health Diary
<input type="text" name="healthDiarySearchString" ng-model="healthDiarySearchString"
ng-change="loadHealthDiaries()" style="width: 300px;margin-left:50px" placeholder="Search using CCC, mood or note."/>
ng-change="loadHealthDiaries()" style="width: 450px;margin-left:50px" placeholder="Search using CCC, mood or note."/>
</div>
<div class="ke-panel-content">
<table class="ke-table-vertical">
Expand Down
2 changes: 1 addition & 1 deletion omod/src/main/webapp/fragments/redFlags.gsp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="ke-panel-frame" ng-controller="RedFlagsCtrl" ng-init="init()">
<div class="ke-panel-heading">Red Flags
<input type="text" name="redFlagsSearchString" ng-model="redFlagsSearchString"
ng-change="loadRedFlags()" style="width: 300px;margin-left:50px" placeholder="Search using CCC, client name, client contact and status."/>
ng-change="loadRedFlags()" style="width: 450px;margin-left:50px" placeholder="Search using CCC, client name, client contact and status."/>
</div>
<div class="ke-panel-content">
<table class="ke-table-vertical">
Expand Down
2 changes: 1 addition & 1 deletion omod/src/main/webapp/fragments/screeningTool.gsp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="ke-panel-frame" ng-controller="ScreeningToolCtrl" ng-init="init()">
<div class="ke-panel-heading">Screening Tool Red Flags
<input type="text" name="screeningToolRedFlagSearchString" ng-model="screeningToolRedFlagSearchString"
ng-change="loadScreeningToolRedFlags()" style="width: 300px;margin-left:50px" placeholder="Search using CCC, client name, client contact, request, screening tool name and status."/>
ng-change="loadScreeningToolRedFlags()" style="width: 450px;margin-left:50px" placeholder="Search using CCC, client name, client contact, request, screening tool name and status."/>
</div>
<div class="ke-panel-content">
<table class="ke-table-vertical">
Expand Down

0 comments on commit 24086b8

Please sign in to comment.