Skip to content
This repository has been archived by the owner on Jan 9, 2023. It is now read-only.

feat(patients): adds ability to view patient #1691

Merged
merged 3 commits into from
Jan 2, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(patients): fix 'Attempted to log TypeError: Cannot read property …
…'body' of null' warning
  • Loading branch information
jackcmeyer committed Jan 2, 2020
commit 2c439d613af90ef1398d1bed7a4553a4b15ca6bf
13 changes: 13 additions & 0 deletions src/__tests__/patients/new/NewPatient.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import React from 'react'
import { mount } from 'enzyme'
import { MemoryRouter } from 'react-router'
import { Provider } from 'react-redux'
import { mocked } from 'ts-jest/utils'
import NewPatient from '../../../patients/new/NewPatient'
import NewPatientForm from '../../../patients/new/NewPatientForm'
import store from '../../../store'
import Patient from '../../../model/Patient'
import * as patientSlice from '../../../patients/patients-slice'
import * as titleUtil from '../../../util/useTitle'
import PatientRepository from '../../../clients/db/PatientRepository'

describe('New Patient', () => {
it('should render a new patient form', () => {
Expand Down Expand Up @@ -38,6 +40,17 @@ describe('New Patient', () => {

it('should call create patient when save button is clicked', async () => {
jest.spyOn(patientSlice, 'createPatient')
jest.spyOn(PatientRepository, 'save')
const mockedPatientRepository = mocked(PatientRepository, true)
const patient = {
id: '123',
prefix: 'test',
givenName: 'test',
familyName: 'test',
suffix: 'test',
} as Patient
mockedPatientRepository.save.mockResolvedValue(patient)

const expectedPatient = {
sex: 'male',
givenName: 'givenName',
Expand Down