@@ -307,6 +307,161 @@ describe('General Information, without isEditable', () => {
307
307
} )
308
308
} )
309
309
310
+ describe ( 'General Information, with isEditable and without patient.id' , ( ) => {
311
+ const patient = { } as Patient
312
+
313
+ let wrapper : ReactWrapper
314
+ let history = createMemoryHistory ( )
315
+
316
+ const error = {
317
+ message : 'some message' ,
318
+ givenName : 'given name message' ,
319
+ dateOfBirth : 'date of birth message' ,
320
+ phoneNumbers : [ 'phone number message' ] ,
321
+ emails : [ 'email message' ] ,
322
+ }
323
+
324
+ const store = mockStore ( { patient : { patient : { } as Patient , createError : error } } as any )
325
+
326
+ const onFieldChange = jest . fn ( )
327
+
328
+ beforeEach ( ( ) => {
329
+ jest . restoreAllMocks ( )
330
+ Date . now = jest . fn ( ) . mockReturnValue ( new Date ( ) . valueOf ( ) )
331
+ history = createMemoryHistory ( )
332
+ wrapper = mount (
333
+ < Provider store = { store } >
334
+ < Router history = { history } >
335
+ < GeneralInformation
336
+ patient = { patient }
337
+ onFieldChange = { onFieldChange }
338
+ onObjectArrayChange = { jest . fn ( ) }
339
+ onTempObjectArrayChange = { jest . fn ( ) }
340
+ isEditable
341
+ />
342
+ )
343
+ </ Router >
344
+ </ Provider > ,
345
+ )
346
+ } )
347
+
348
+ const expectedPhoneNumberType = 'expectedPhoneNumberType'
349
+ const expectedPhoneNumber = 'expectedPhoneNumber'
350
+ const expectedEmailType = 'expectedEmailType'
351
+ const expectedEmail = 'expectedEmail'
352
+ const expectedAddressType = 'expectedAddressType'
353
+ const expectedAddress = 'expectedAddress'
354
+
355
+ it ( 'should render the Phone Number Type of the Patient' , ( ) => {
356
+ const phoneNumberTypeSelect = wrapper . findWhere (
357
+ ( w : any ) => w . prop ( 'name' ) === 'temporaryPhoneNumberType' ,
358
+ )
359
+
360
+ expect ( phoneNumberTypeSelect . prop ( 'label' ) ) . toEqual ( 'patient.phoneNumber.type' )
361
+ expect ( phoneNumberTypeSelect . prop ( 'isEditable' ) ) . toBeTruthy ( )
362
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) ) . toHaveLength ( 5 )
363
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 0 ] . label ) . toEqual ( 'patient.phoneNumber.types.home' )
364
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 0 ] . value ) . toEqual ( 'home' )
365
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 1 ] . label ) . toEqual ( 'patient.phoneNumber.types.work' )
366
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 1 ] . value ) . toEqual ( 'work' )
367
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 2 ] . label ) . toEqual (
368
+ 'patient.phoneNumber.types.temporary' ,
369
+ )
370
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 2 ] . value ) . toEqual ( 'temporary' )
371
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 3 ] . label ) . toEqual ( 'patient.phoneNumber.types.old' )
372
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 3 ] . value ) . toEqual ( 'old' )
373
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 4 ] . label ) . toEqual (
374
+ 'patient.phoneNumber.types.mobile' ,
375
+ )
376
+ expect ( phoneNumberTypeSelect . prop ( 'options' ) [ 4 ] . value ) . toEqual ( 'mobile' )
377
+
378
+ act ( ( ) => {
379
+ phoneNumberTypeSelect . prop ( 'onChange' ) ( { target : { value : expectedPhoneNumberType } } )
380
+ } )
381
+ } )
382
+
383
+ it ( 'should render the phone number of the patient' , ( ) => {
384
+ const phoneNumberInput = wrapper . findWhere (
385
+ ( w : any ) => w . prop ( 'name' ) === 'temporaryPhoneNumber' ,
386
+ )
387
+
388
+ expect ( phoneNumberInput . prop ( 'label' ) ) . toEqual ( 'patient.phoneNumber.phoneNumber' )
389
+ expect ( phoneNumberInput . prop ( 'isEditable' ) ) . toBeTruthy ( )
390
+
391
+ act ( ( ) => {
392
+ phoneNumberInput . prop ( 'onChange' ) ( { target : { value : expectedPhoneNumber } } )
393
+ } )
394
+ } )
395
+
396
+ it ( 'should render the Email Type of the Patient' , ( ) => {
397
+ const emailTypeSelect = wrapper . findWhere ( ( w : any ) => w . prop ( 'name' ) === 'temporaryEmailType' )
398
+
399
+ expect ( emailTypeSelect . prop ( 'label' ) ) . toEqual ( 'patient.email.type' )
400
+ expect ( emailTypeSelect . prop ( 'isEditable' ) ) . toBeTruthy ( )
401
+ expect ( emailTypeSelect . prop ( 'options' ) ) . toHaveLength ( 5 )
402
+ expect ( emailTypeSelect . prop ( 'options' ) [ 0 ] . label ) . toEqual ( 'patient.email.types.home' )
403
+ expect ( emailTypeSelect . prop ( 'options' ) [ 0 ] . value ) . toEqual ( 'home' )
404
+ expect ( emailTypeSelect . prop ( 'options' ) [ 1 ] . label ) . toEqual ( 'patient.email.types.work' )
405
+ expect ( emailTypeSelect . prop ( 'options' ) [ 1 ] . value ) . toEqual ( 'work' )
406
+ expect ( emailTypeSelect . prop ( 'options' ) [ 2 ] . label ) . toEqual ( 'patient.email.types.temporary' )
407
+ expect ( emailTypeSelect . prop ( 'options' ) [ 2 ] . value ) . toEqual ( 'temporary' )
408
+ expect ( emailTypeSelect . prop ( 'options' ) [ 3 ] . label ) . toEqual ( 'patient.email.types.old' )
409
+ expect ( emailTypeSelect . prop ( 'options' ) [ 3 ] . value ) . toEqual ( 'old' )
410
+ expect ( emailTypeSelect . prop ( 'options' ) [ 4 ] . label ) . toEqual ( 'patient.email.types.mobile' )
411
+ expect ( emailTypeSelect . prop ( 'options' ) [ 4 ] . value ) . toEqual ( 'mobile' )
412
+
413
+ act ( ( ) => {
414
+ emailTypeSelect . prop ( 'onChange' ) ( { target : { value : expectedEmailType } } )
415
+ } )
416
+ } )
417
+
418
+ it ( 'should render the email of the patient' , ( ) => {
419
+ const emailInput = wrapper . findWhere ( ( w : any ) => w . prop ( 'name' ) === 'temporaryEmail' )
420
+
421
+ expect ( emailInput . prop ( 'label' ) ) . toEqual ( 'patient.email.email' )
422
+ expect ( emailInput . prop ( 'isEditable' ) ) . toBeTruthy ( )
423
+
424
+ act ( ( ) => {
425
+ emailInput . prop ( 'onChange' ) ( { target : { value : expectedEmail } } )
426
+ } )
427
+ } )
428
+
429
+ it ( 'should render the Address Type of the Patient' , ( ) => {
430
+ const addressTypeSelect = wrapper . findWhere (
431
+ ( w : any ) => w . prop ( 'name' ) === 'temporaryAddressType' ,
432
+ )
433
+
434
+ expect ( addressTypeSelect . prop ( 'label' ) ) . toEqual ( 'patient.address.type' )
435
+ expect ( addressTypeSelect . prop ( 'isEditable' ) ) . toBeTruthy ( )
436
+ expect ( addressTypeSelect . prop ( 'options' ) ) . toHaveLength ( 5 )
437
+ expect ( addressTypeSelect . prop ( 'options' ) [ 0 ] . label ) . toEqual ( 'patient.address.types.home' )
438
+ expect ( addressTypeSelect . prop ( 'options' ) [ 0 ] . value ) . toEqual ( 'home' )
439
+ expect ( addressTypeSelect . prop ( 'options' ) [ 1 ] . label ) . toEqual ( 'patient.address.types.work' )
440
+ expect ( addressTypeSelect . prop ( 'options' ) [ 1 ] . value ) . toEqual ( 'work' )
441
+ expect ( addressTypeSelect . prop ( 'options' ) [ 2 ] . label ) . toEqual ( 'patient.address.types.temporary' )
442
+ expect ( addressTypeSelect . prop ( 'options' ) [ 2 ] . value ) . toEqual ( 'temporary' )
443
+ expect ( addressTypeSelect . prop ( 'options' ) [ 3 ] . label ) . toEqual ( 'patient.address.types.old' )
444
+ expect ( addressTypeSelect . prop ( 'options' ) [ 3 ] . value ) . toEqual ( 'old' )
445
+ expect ( addressTypeSelect . prop ( 'options' ) [ 4 ] . label ) . toEqual ( 'patient.address.types.billing' )
446
+ expect ( addressTypeSelect . prop ( 'options' ) [ 4 ] . value ) . toEqual ( 'billing' )
447
+
448
+ act ( ( ) => {
449
+ addressTypeSelect . prop ( 'onChange' ) ( { target : { value : expectedAddressType } } )
450
+ } )
451
+ } )
452
+
453
+ it ( 'should render the address of the patient' , ( ) => {
454
+ const addressInput = wrapper . findWhere ( ( w : any ) => w . prop ( 'name' ) === 'temporaryAddress' )
455
+
456
+ expect ( addressInput . prop ( 'label' ) ) . toEqual ( 'patient.address.address' )
457
+ expect ( addressInput . prop ( 'isEditable' ) ) . toBeTruthy ( )
458
+
459
+ act ( ( ) => {
460
+ addressInput . prop ( 'onChange' ) ( { target : { value : expectedAddress } } )
461
+ } )
462
+ } )
463
+ } )
464
+
310
465
describe ( 'General Information, isEditable' , ( ) => {
311
466
const patient = {
312
467
id : '123' ,
0 commit comments