Skip to content

Commit

Permalink
(test) Remove unnecessary partial mocks and improve typing (#1251)
Browse files Browse the repository at this point in the history
* (test) Remove unnecessary partial mocks and improve typing

* Review feedback

* Type openmrsFetch mocks
  • Loading branch information
denniskigen authored Jul 30, 2024
1 parent e0a71ec commit 73bb46e
Show file tree
Hide file tree
Showing 160 changed files with 2,861 additions and 2,158 deletions.
478 changes: 445 additions & 33 deletions __mocks__/identifier-types.mock.ts

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion __mocks__/identifiers.mock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const openmrsID = {
name: 'OpenMRS ID',
fieldName: 'openMrsId',
fieldName: 'OpenMRS ID',
required: true,
uuid: '05a29f94-c0ed-11e2-94be-8c13b969e334',
format: null,
Expand All @@ -24,4 +24,5 @@ export const openmrsID = {
},
],
autoGenerationSource: null,
uniquenessBehavior: 'UNIQUE' as const,
};
30 changes: 15 additions & 15 deletions __mocks__/patient-registration.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,57 +5,57 @@ export const mockedAddressTemplate = {
lines: [
[
{
isToken: 'IS_NOT_ADDR_TOKEN',
isToken: 'IS_NOT_ADDR_TOKEN' as const,
displayText: '',
},
{
isToken: 'IS_ADDR_TOKEN',
isToken: 'IS_ADDR_TOKEN' as const,
displayText: 'Village',
codeName: 'cityVillage',
codeName: 'cityVillage' as const,
displaySize: '40',
},
{
isToken: 'IS_NOT_ADDR_TOKEN',
isToken: 'IS_NOT_ADDR_TOKEN' as const,
displayText: ', ',
},
{
isToken: 'IS_ADDR_TOKEN',
isToken: 'IS_ADDR_TOKEN' as const,
displayText: 'Commune',
codeName: 'address1',
codeName: 'address1' as const,
displaySize: '40',
},
],
[
{
isToken: 'IS_NOT_ADDR_TOKEN',
isToken: 'IS_NOT_ADDR_TOKEN' as const,
displayText: '',
},
{
isToken: 'IS_ADDR_TOKEN',
isToken: 'IS_ADDR_TOKEN' as const,
displayText: 'District',
codeName: 'countyDistrict',
codeName: 'countyDistrict' as const,
displaySize: '40',
},
{
isToken: 'IS_NOT_ADDR_TOKEN',
isToken: 'IS_NOT_ADDR_TOKEN' as const,
displayText: ', ',
},
{
isToken: 'IS_ADDR_TOKEN',
isToken: 'IS_ADDR_TOKEN' as const,
displayText: 'Province',
codeName: 'stateProvince',
codeName: 'stateProvince' as const,
displaySize: '40',
},
],
[
{
isToken: 'IS_NOT_ADDR_TOKEN',
isToken: 'IS_NOT_ADDR_TOKEN' as const,
displayText: '',
},
{
isToken: 'IS_ADDR_TOKEN',
isToken: 'IS_ADDR_TOKEN' as const,
displayText: 'Country',
codeName: 'country',
codeName: 'country' as const,
displaySize: '40',
},
],
Expand Down
8 changes: 6 additions & 2 deletions __mocks__/patient-visits.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,19 @@ export const mockPatientsVisits = {
identifier: 'M4T4J',
name: 'WILLIAM LAGAT',
uuid: 'cd34e972-a325-4371-9b2a-57ba82d628ab',
gender: 'male',
age: '29',
phoneNumber: null,
},
service: {
appointmentServiceId: 1,
name: 'Cardiology Consultation 1',
description: null,
speciality: {},
speciality: null,
startTime: '09:00:00',
endTime: '17:30:00',
maxAppointmentsLimit: 30,
durationMins: 30,
durationMins: '30',
location: {
name: '10 Engineer VCT',
uuid: '673d1efd-6a96-47c3-a332-54c30d9f0c29',
Expand All @@ -25,6 +28,7 @@ export const mockPatientsVisits = {
color: '#00ff00',
initialAppointmentStatus: null,
creatorName: null,
serviceTypes: [],
},
serviceType: null,
provider: null,
Expand Down
4 changes: 0 additions & 4 deletions __mocks__/patient.mock.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { type Patient, type PersonAddress } from '@openmrs/esm-framework';
import { mockAddress } from './address.mock';
import { mockPastVisit } from './visits.mock';
import { mockLocationInpatientWard } from './locations.mock';

/* Patients as returned by `usePatient` and the service queues endpoints */

export const mockPatientAlice: Patient = {
uuid: '00000000-0000-0001-0000-000000000000',
display: 'Alice Johnson',
Expand Down Expand Up @@ -49,7 +46,6 @@ export const mockPatientBrian: Patient = {
dead: false,
deathDate: null,
causeOfDeath: null,
preferredName: null,
preferredAddress: mockAddress as PersonAddress,
preferredName: {
display: 'Brian Johnson',
Expand Down
10 changes: 9 additions & 1 deletion __mocks__/queue-entry.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,19 @@ export const mockQueueEntryAlice: QueueEntry = {
attributes: [
{
attributeType: {
uuid: 'queue-number-visit-attr-uuid',
uuid: 'queue-number-visit-attr-type-uuid',
},
value: '42',
uuid: 'queue-number-visit-attr-uuid',
},
],
encounters: [],
visitType: {
uuid: 'visit-type-uuid',
display: 'Facility Visit',
},
visitTypeUuid: 'visit-type-uuid',
startDatetime: '2022-04-03T07:22:00.000+0000',
} as Visit,
sortWeight: 0,
queueComingFrom: mockQueueTriage,
Expand Down
11 changes: 6 additions & 5 deletions __mocks__/session.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,28 @@ export const mockSession = {
display: 'admin',
username: '',
systemId: 'admin',
locale: 'en',
allowedLocales: ['en', 'en-GB', 'es', 'fr', 'he', 'km'],
userProperties: {
loginAttempts: '0',
},
person: {
uuid: '0775e6b7-f439-40e5-87a3-2bd11f3b9ee5',
display: 'Test User',
links: [],
},
links: [],
privileges: [
{
uuid: '62431c71-5244-11ea-a771-0242ac160002',
display: 'Manage Appointment Services',
links: [],
},
{
uuid: '6206682c-5244-11ea-a771-0242ac160002',
display: 'Manage Appointments',
links: [],
},
{
uuid: '6280ff58-5244-11ea-a771-0242ac160002',
display: 'Manage Appointment Specialities',
links: [],
},
],
roles: [
Expand All @@ -110,7 +109,9 @@ export const mockSession = {
},
],
retired: false,
locale: 'en_GB',
allowedLocales: ['en_GB'],
},
sessionId: '39570a50-abb2-4f44-b146-a288ec35064b',
sessionId: 'D4F7D4D4-6A6D-4D4D-8D4D-4D4D4D4D4D4D',
},
};
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
const path = require('path');

module.exports = {
clearMocks: true,
transform: {
'^.+\\.(j|t)sx?$': '@swc/jest',
},
Expand Down
Loading

0 comments on commit 73bb46e

Please sign in to comment.