fhir-react 0.3.5 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +1 -1
  2. package/build/index.js +6 -6
  3. package/package.json +1 -1
  4. package/src/assets/containers/{Medication/medication.svg → MedicationOrder/medication-order.svg} +0 -0
  5. package/src/assets/containers/MedicationRequest/medication-request.svg +5 -0
  6. package/src/assets/containers/ResourceCategory/{resource-placeholder.svg → resource-category.svg} +0 -0
  7. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.js +3 -5
  8. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.stories.js +5 -4
  9. package/src/components/resources/AllergyIntolerance/AllergyIntolerance.test.js +71 -0
  10. package/src/components/resources/Binary/Binary.js +1 -2
  11. package/src/components/resources/Binary/Binary.stories.js +10 -4
  12. package/src/components/resources/Binary/Binary.test.js +67 -0
  13. package/src/components/resources/CarePlan/CarePlan.stories.js +31 -5
  14. package/src/components/resources/CarePlan/CarePlan.test.js +72 -0
  15. package/src/components/resources/Device/Device.stories.js +33 -5
  16. package/src/components/resources/Device/Device.test.js +72 -0
  17. package/src/components/resources/DiagnosticReport/DiagnosticReport.stories.js +5 -4
  18. package/src/components/resources/DiagnosticReport/DiagnosticReport.test.js +71 -0
  19. package/src/components/resources/DocumentReference/DocumentReference.stories.js +3 -2
  20. package/src/components/resources/DocumentReference/DocumentReference.test.js +71 -0
  21. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.stories.js +3 -2
  22. package/src/components/resources/FamilyMemberHistory/FamilyMemberHistory.test.js +72 -0
  23. package/src/components/resources/Goal/Goal.js +1 -2
  24. package/src/components/resources/Goal/Goal.stories.js +5 -4
  25. package/src/components/resources/Goal/Goal.test.js +69 -0
  26. package/src/components/resources/Medication/Medication.test.js +1 -1
  27. package/src/components/resources/MedicationKnowledge/MedicationKnowledge.js +1 -1
  28. package/src/components/resources/MedicationOrder/MedicationOrder.js +2 -2
  29. package/src/components/resources/MedicationOrder/MedicationOrder.stories.js +1 -2
  30. package/src/components/resources/MedicationOrder/MedicationOrder.test.js +67 -0
  31. package/src/components/resources/MedicationRequest/MedicationRequest.js +2 -4
  32. package/src/components/resources/MedicationRequest/MedicationRequest.stories.js +11 -6
  33. package/src/components/resources/MedicationRequest/MedicationRequest.test.js +67 -0
  34. package/src/components/resources/MedicationStatement/MedicationDosage.js +2 -2
  35. package/src/components/resources/MedicationStatement/MedicationStatement.js +1 -0
  36. package/src/components/resources/MedicationStatement/MedicationStatement.stories.js +5 -4
  37. package/src/components/resources/MedicationStatement/MedicationStatement.test.js +72 -0
  38. package/src/components/resources/ResourceCategory/ResourceCategory.js +7 -12
  39. package/src/components/resources/ResourceCategory/ResourceCategory.stories.js +13 -2
  40. package/src/components/resources/ResourceCategory/ResourceCategory.test.js +77 -18
  41. package/src/fixtures/example-icons.jsx +20 -13
@@ -7,8 +7,79 @@ import exampleDiagnosticReportDSTU2 from '../../../fixtures/dstu2/resources/diag
7
7
  import exampleDiagnosticReportSTU3 from '../../../fixtures/stu3/resources/diagnosticReport/example1.json';
8
8
  import exampleDiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example1.json';
9
9
  import example2DiagnosticReportR4 from '../../../fixtures/r4/resources/diagnosticReport/example2.json';
10
+ import fhirIcons from '../../../fixtures/example-icons';
10
11
 
11
12
  describe('should render component correctly', () => {
13
+ it('component without a fhirIcons props should render a default icon', () => {
14
+ const defaultProps = {
15
+ fhirResource: exampleDiagnosticReportDSTU2,
16
+ fhirVersion: fhirVersions.DSTU2,
17
+ };
18
+
19
+ const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
20
+ const headerIcon = getByAltText('diagnostic report');
21
+
22
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
23
+ });
24
+
25
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
26
+ const defaultProps = {
27
+ fhirResource: exampleDiagnosticReportDSTU2,
28
+ fhirVersion: fhirVersions.DSTU2,
29
+ fhirIcons: false,
30
+ };
31
+
32
+ const { getByTestId } = render(<DiagnosticReport {...defaultProps} />);
33
+ const headerIcon = getByTestId('placeholder');
34
+
35
+ expect(headerIcon).toBeTruthy();
36
+ });
37
+
38
+ it('component with the img as a fhirIcons props should render an img', () => {
39
+ const defaultProps = {
40
+ fhirResource: exampleDiagnosticReportDSTU2,
41
+ fhirVersion: fhirVersions.DSTU2,
42
+ fhirIcons: (
43
+ <img
44
+ src={require('../assets/containers/DiagnosticReport/diagnostic-report.svg')}
45
+ alt="diagnostic report"
46
+ />
47
+ ),
48
+ };
49
+
50
+ const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
51
+ const headerIcon = getByAltText('diagnostic report');
52
+
53
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
54
+ });
55
+
56
+ it('component with the resources object as a fhirIcons props should render an img', () => {
57
+ const defaultProps = {
58
+ fhirResource: exampleDiagnosticReportDSTU2,
59
+ fhirVersion: fhirVersions.DSTU2,
60
+ fhirIcons: fhirIcons,
61
+ };
62
+
63
+ const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
64
+ const headerIcon = getByAltText('diagnostic report');
65
+
66
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
67
+ });
68
+
69
+ it('component with the url as a fhirIcons props should render an img', () => {
70
+ const avatarSrc =
71
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
72
+ const defaultProps = {
73
+ fhirResource: exampleDiagnosticReportDSTU2,
74
+ fhirVersion: fhirVersions.DSTU2,
75
+ fhirIcons: avatarSrc,
76
+ };
77
+
78
+ const { getByAltText } = render(<DiagnosticReport {...defaultProps} />);
79
+ const headerIcon = getByAltText('header icon');
80
+
81
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
82
+ });
12
83
  it('should render with DSTU2 source data', () => {
13
84
  const defaultProps = {
14
85
  fhirResource: exampleDiagnosticReportDSTU2,
@@ -8,6 +8,7 @@ import exampleDocumentReference from '../../../fixtures/dstu2/resources/document
8
8
  import exampleDocumentReferenceSTU3 from '../../../fixtures/stu3/resources/documentReference/example1.json';
9
9
  import example1DocumentReferenceR4 from '../../../fixtures/r4/resources/documentReference/example1.json';
10
10
  import fhirIcons from '../../../fixtures/example-icons';
11
+ import DocumentReferenceIcon from '../../../assets/containers/DocumentReference/document-reference.svg';
11
12
 
12
13
  export default { title: 'Document Reference' };
13
14
 
@@ -17,7 +18,7 @@ export const DefaultVisualizationDSTU2 = () => {
17
18
  <DocumentReference
18
19
  fhirResource={fhirResource}
19
20
  fhirVersion={fhirVersions.DSTU2}
20
- fhirIcons={fhirIcons}
21
+ fhirIcons={require('../../../assets/containers/DocumentReference/document-reference.svg')}
21
22
  />
22
23
  );
23
24
  };
@@ -28,7 +29,7 @@ export const ExampleSTU3 = () => {
28
29
  <DocumentReference
29
30
  fhirResource={fhirResource}
30
31
  fhirVersion={fhirVersions.STU3}
31
- fhirIcons={fhirIcons}
32
+ fhirIcons={DocumentReferenceIcon}
32
33
  />
33
34
  );
34
35
  };
@@ -8,8 +8,79 @@ import DocumentReference from './DocumentReference';
8
8
  import dstu2Example1 from '../../../fixtures/dstu2/resources/documentReference/example1.json';
9
9
  import stu3Example1 from '../../../fixtures/stu3/resources/documentReference/example1.json';
10
10
  import r4Example1 from '../../../fixtures/r4/resources/documentReference/example1.json';
11
+ import fhirIcons from '../../../fixtures/example-icons';
11
12
 
12
13
  describe('should render the DocumentReference component properly', () => {
14
+ it('component without a fhirIcons props should render a default icon', () => {
15
+ const defaultProps = {
16
+ fhirResource: dstu2Example1,
17
+ fhirVersion: fhirVersions.DSTU2,
18
+ };
19
+
20
+ const { getByAltText } = render(<DocumentReference {...defaultProps} />);
21
+ const headerIcon = getByAltText('document reference');
22
+
23
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
24
+ });
25
+
26
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
27
+ const defaultProps = {
28
+ fhirResource: dstu2Example1,
29
+ fhirVersion: fhirVersions.DSTU2,
30
+ fhirIcons: false,
31
+ };
32
+
33
+ const { getByTestId } = render(<DocumentReference {...defaultProps} />);
34
+ const headerIcon = getByTestId('placeholder');
35
+
36
+ expect(headerIcon).toBeTruthy();
37
+ });
38
+
39
+ it('component with the img as a fhirIcons props should render an img', () => {
40
+ const defaultProps = {
41
+ fhirResource: dstu2Example1,
42
+ fhirVersion: fhirVersions.DSTU2,
43
+ fhirIcons: (
44
+ <img
45
+ src={require('../assets/containers/DocumentReference/document-reference.svg')}
46
+ alt="document reference"
47
+ />
48
+ ),
49
+ };
50
+
51
+ const { getByAltText } = render(<DocumentReference {...defaultProps} />);
52
+ const headerIcon = getByAltText('document reference');
53
+
54
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
55
+ });
56
+
57
+ it('component with the resources object as a fhirIcons props should render an img', () => {
58
+ const defaultProps = {
59
+ fhirResource: dstu2Example1,
60
+ fhirVersion: fhirVersions.DSTU2,
61
+ fhirIcons: fhirIcons,
62
+ };
63
+
64
+ const { getByAltText } = render(<DocumentReference {...defaultProps} />);
65
+ const headerIcon = getByAltText('document reference');
66
+
67
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
68
+ });
69
+
70
+ it('component with the url as a fhirIcons props should render an img', () => {
71
+ const avatarSrc =
72
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
73
+ const defaultProps = {
74
+ fhirResource: dstu2Example1,
75
+ fhirVersion: fhirVersions.DSTU2,
76
+ fhirIcons: avatarSrc,
77
+ };
78
+
79
+ const { getByAltText } = render(<DocumentReference {...defaultProps} />);
80
+ const headerIcon = getByAltText('header icon');
81
+
82
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
83
+ });
13
84
  it('should render with DSTU2 source data', () => {
14
85
  const { getByTestId } = render(
15
86
  <DocumentReference
@@ -9,6 +9,7 @@ import example1DSTU2 from '../../../fixtures/dstu2/resources/familyMemberHistory
9
9
  import example1STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example1.json';
10
10
  import example2STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example2.json';
11
11
  import fhirIcons from '../../../fixtures/example-icons';
12
+ import FamilyMemberHistoryIcon from '../../../assets/containers/FamilyMemberHistory/family-member-history.svg';
12
13
 
13
14
  export default {
14
15
  title: 'FamilyMemberHistory',
@@ -20,7 +21,7 @@ export const DefaultVisualizationDSTU2 = () => {
20
21
  <FamilyMemberHistory
21
22
  fhirVersion={fhirVersions.DSTU2}
22
23
  fhirResource={fhirResource}
23
- fhirIcons={fhirIcons}
24
+ fhirIcons={require('../../../assets/containers/FamilyMemberHistory/family-member-history.svg')}
24
25
  />
25
26
  );
26
27
  };
@@ -31,7 +32,7 @@ export const Example1OfSTU3 = () => {
31
32
  <FamilyMemberHistory
32
33
  fhirVersion={fhirVersions.STU3}
33
34
  fhirResource={fhirResource}
34
- fhirIcons={fhirIcons}
35
+ fhirIcons={FamilyMemberHistoryIcon}
35
36
  />
36
37
  );
37
38
  };
@@ -5,8 +5,80 @@ import fhirVersions from '../fhirResourceVersions';
5
5
 
6
6
  import example1DSTU2 from '../../../fixtures/dstu2/resources/familyMemberHistory/example1.json';
7
7
  import example1STU3 from '../../../fixtures/stu3/resources/familyMemberHistory/example1.json';
8
+ import fhirIcons from '../../../fixtures/example-icons';
8
9
 
9
10
  describe('should render FamilyMemberHistory component correctly', () => {
11
+ it('component without a fhirIcons props should render a default icon', () => {
12
+ const defaultProps = {
13
+ fhirResource: example1DSTU2,
14
+ fhirVersion: fhirVersions.DSTU2,
15
+ };
16
+
17
+ const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
18
+ const headerIcon = getByAltText('family member history');
19
+
20
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
21
+ });
22
+
23
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
24
+ const defaultProps = {
25
+ fhirResource: example1DSTU2,
26
+ fhirVersion: fhirVersions.DSTU2,
27
+ fhirIcons: false,
28
+ };
29
+
30
+ const { getByTestId } = render(<FamilyMemberHistory {...defaultProps} />);
31
+ const headerIcon = getByTestId('placeholder');
32
+
33
+ expect(headerIcon).toBeTruthy();
34
+ });
35
+
36
+ it('component with the img as a fhirIcons props should render an img', () => {
37
+ const defaultProps = {
38
+ fhirResource: example1DSTU2,
39
+ fhirVersion: fhirVersions.DSTU2,
40
+ fhirIcons: (
41
+ <img
42
+ src={require('../assets/containers/FamilyMemberHistory/family-member-history.svg')}
43
+ alt="family member history"
44
+ />
45
+ ),
46
+ };
47
+
48
+ const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
49
+ const headerIcon = getByAltText('family member history');
50
+
51
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
52
+ });
53
+
54
+ it('component with the resources object as a fhirIcons props should render an img', () => {
55
+ const defaultProps = {
56
+ fhirResource: example1DSTU2,
57
+ fhirVersion: fhirVersions.DSTU2,
58
+ fhirIcons: fhirIcons,
59
+ };
60
+
61
+ const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
62
+ const headerIcon = getByAltText('family member history');
63
+
64
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
65
+ });
66
+
67
+ it('component with the url as a fhirIcons props should render an img', () => {
68
+ const avatarSrc =
69
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
70
+ const defaultProps = {
71
+ fhirResource: example1DSTU2,
72
+ fhirVersion: fhirVersions.DSTU2,
73
+ fhirIcons: avatarSrc,
74
+ };
75
+
76
+ const { getByAltText } = render(<FamilyMemberHistory {...defaultProps} />);
77
+ const headerIcon = getByAltText('header icon');
78
+
79
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
80
+ });
81
+
10
82
  it('DSTU2', () => {
11
83
  const defaultProps = {
12
84
  fhirResource: example1DSTU2,
@@ -101,7 +101,6 @@ const resourceDTO = (fhirVersion, fhirResource) => {
101
101
 
102
102
  const Goal = props => {
103
103
  const { fhirResource, fhirVersion, fhirIcons } = props;
104
- const headerIcon = fhirIcons && fhirIcons['Goal'];
105
104
 
106
105
  let fhirResourceData = {};
107
106
  try {
@@ -225,7 +224,7 @@ const Goal = props => {
225
224
  )
226
225
  }
227
226
  badges={hasStatus && <Badge data-testid="status">{status}</Badge>}
228
- icon={headerIcon}
227
+ icon={fhirIcons}
229
228
  title={title}
230
229
  />
231
230
  }
@@ -9,6 +9,7 @@ import stu3Example1 from '../../../fixtures/stu3/resources/goal/example1.json';
9
9
  import r4Example1 from '../../../fixtures/r4/resources/goal/example1.json';
10
10
  import r4Example2 from '../../../fixtures/r4/resources/goal/example2.json';
11
11
  import fhirVersions from '../fhirResourceVersions';
12
+ import GoalIcon from '../../../assets/containers/Goal/goal.svg';
12
13
 
13
14
  export default {
14
15
  title: 'Goal',
@@ -20,7 +21,7 @@ export const DefaultVisualizationDSTU2 = () => {
20
21
  <Goal
21
22
  fhirVersion={fhirVersions.DSTU2}
22
23
  fhirResource={fhirResource}
23
- fhirIcons={fhirIcons}
24
+ fhirIcons={require('../../../assets/containers/Goal/goal.svg')}
24
25
  />
25
26
  );
26
27
  };
@@ -31,7 +32,7 @@ export const Example2OfDSTU2 = () => {
31
32
  <Goal
32
33
  fhirVersion={fhirVersions.DSTU2}
33
34
  fhirResource={fhirResource}
34
- fhirIcons={fhirIcons}
35
+ fhirIcons={GoalIcon}
35
36
  />
36
37
  );
37
38
  };
@@ -53,7 +54,7 @@ export const Example1OfR4 = () => {
53
54
  <Goal
54
55
  fhirVersion={fhirVersions.R4}
55
56
  fhirResource={fhirResource}
56
- fhirIcons={fhirIcons}
57
+ fhirIcons={false}
57
58
  />
58
59
  );
59
60
  };
@@ -64,7 +65,7 @@ export const Example2OfR4 = () => {
64
65
  <Goal
65
66
  fhirVersion={fhirVersions.R4}
66
67
  fhirResource={fhirResource}
67
- fhirIcons={fhirIcons}
68
+ fhirIcons={'random text'}
68
69
  />
69
70
  );
70
71
  };
@@ -7,8 +7,77 @@ import dstu2Example1 from '../../../fixtures/dstu2/resources/goal/example1.json'
7
7
  import stu3Example1 from '../../../fixtures/stu3/resources/goal/example1.json';
8
8
  import r4Example1 from '../../../fixtures/r4/resources/goal/example1.json';
9
9
  import r4Example2 from '../../../fixtures/r4/resources/goal/example2.json';
10
+ import fhirIcons from '../../../fixtures/example-icons';
10
11
 
11
12
  describe('should render Goal component properly', () => {
13
+ it('component without a fhirIcons props should render a default icon', () => {
14
+ const defaultProps = {
15
+ fhirResource: dstu2Example1,
16
+ fhirVersion: fhirVersions.DSTU2,
17
+ };
18
+
19
+ const { getByAltText } = render(<Goal {...defaultProps} />);
20
+ const headerIcon = getByAltText('goal');
21
+
22
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
23
+ });
24
+
25
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
26
+ const defaultProps = {
27
+ fhirResource: dstu2Example1,
28
+ fhirVersion: fhirVersions.DSTU2,
29
+ fhirIcons: false,
30
+ };
31
+
32
+ const { getByTestId } = render(<Goal {...defaultProps} />);
33
+ const headerIcon = getByTestId('placeholder');
34
+
35
+ expect(headerIcon).toBeTruthy();
36
+ });
37
+
38
+ it('component with the img as a fhirIcons props should render an img', () => {
39
+ const defaultProps = {
40
+ fhirResource: dstu2Example1,
41
+ fhirVersion: fhirVersions.DSTU2,
42
+ fhirIcons: (
43
+ <img src={require('../assets/containers/Goal/goal.svg')} alt="goal" />
44
+ ),
45
+ };
46
+
47
+ const { getByAltText } = render(<Goal {...defaultProps} />);
48
+ const headerIcon = getByAltText('goal');
49
+
50
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
51
+ });
52
+
53
+ it('component with the resources object as a fhirIcons props should render an img', () => {
54
+ const defaultProps = {
55
+ fhirResource: dstu2Example1,
56
+ fhirVersion: fhirVersions.DSTU2,
57
+ fhirIcons: fhirIcons,
58
+ };
59
+
60
+ const { getByAltText } = render(<Goal {...defaultProps} />);
61
+ const headerIcon = getByAltText('goal');
62
+
63
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
64
+ });
65
+
66
+ it('component with the url as a fhirIcons props should render an img', () => {
67
+ const avatarSrc =
68
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
69
+ const defaultProps = {
70
+ fhirResource: dstu2Example1,
71
+ fhirVersion: fhirVersions.DSTU2,
72
+ fhirIcons: avatarSrc,
73
+ };
74
+
75
+ const { getByAltText } = render(<Goal {...defaultProps} />);
76
+ const headerIcon = getByAltText('header icon');
77
+
78
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
79
+ });
80
+
12
81
  it('should render with DSTU2 source data', () => {
13
82
  const defaultProps = {
14
83
  fhirResource: dstu2Example1,
@@ -10,7 +10,7 @@ import stu3Example2 from '../../../fixtures/stu3/resources/medication/example2.j
10
10
  import r4Example1 from '../../../fixtures/r4/resources/medication/example1.json';
11
11
  import r4Example2 from '../../../fixtures/r4/resources/medication/example2.json';
12
12
 
13
- describe('should render Medication component properly', () => {
13
+ describe('should render MedicationOrder component properly', () => {
14
14
  it('should render with DSTU2 source data', () => {
15
15
  const defaultProps = {
16
16
  fhirResource: dstu2Example1,
@@ -142,7 +142,7 @@ const MedicationKnowledge = props => {
142
142
  <Root name="MedicationKnowledge">
143
143
  <Header>
144
144
  <Title>
145
- {id ? `Medication knowledge ID: ${id}` : 'Medication knowledge'}{' '}
145
+ {id ? `Medication knowledge ID: ${id}` : 'MedicationOrder knowledge'}{' '}
146
146
  {status && <Badge data-testid="status">{status}</Badge>}
147
147
  </Title>
148
148
  </Header>
@@ -10,7 +10,7 @@ import { Root, Header, Body } from '../../ui';
10
10
 
11
11
  const MedicationOrder = props => {
12
12
  const { fhirResource, fhirIcons } = props;
13
- const headerIcon = fhirIcons && fhirIcons['Medication'];
13
+
14
14
  const medicationReference = _get(fhirResource, 'medicationReference');
15
15
  const medicationCodeableConcept = _get(
16
16
  fhirResource,
@@ -56,7 +56,7 @@ const MedicationOrder = props => {
56
56
  <Accordion
57
57
  headerContent={
58
58
  <Header
59
- icon={headerIcon}
59
+ icon={fhirIcons}
60
60
  resourceName="MedicationOrder"
61
61
  title={
62
62
  medicationReference && (
@@ -4,7 +4,6 @@ import { object } from '@storybook/addon-knobs';
4
4
  import MedicationOrder from './MedicationOrder';
5
5
 
6
6
  import dstu2Example from '../../../fixtures/dstu2/resources/medicationOrder/example.json';
7
- import fhirIcons from '../../../fixtures/example-icons';
8
7
 
9
8
  export default {
10
9
  title: 'MedicationOrder',
@@ -12,5 +11,5 @@ export default {
12
11
 
13
12
  export const DefaultVisualizationDSTU2 = () => {
14
13
  const fhirResource = object('Resource', dstu2Example);
15
- return <MedicationOrder fhirResource={fhirResource} fhirIcons={fhirIcons} />;
14
+ return <MedicationOrder fhirResource={fhirResource} />;
16
15
  };
@@ -4,8 +4,75 @@ import { render } from '@testing-library/react';
4
4
  import MedicationOrder from './MedicationOrder';
5
5
 
6
6
  import example from '../../../fixtures/dstu2/resources/medicationOrder/example.json';
7
+ import fhirIcons from '../../../fixtures/example-icons';
7
8
 
8
9
  describe('should render MedicationOrder component properly', () => {
10
+ it('component without a fhirIcons props should render a default icon', () => {
11
+ const defaultProps = {
12
+ fhirResource: example,
13
+ };
14
+
15
+ const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
16
+ const headerIcon = getByAltText('medication order');
17
+
18
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
19
+ });
20
+
21
+ it('component with a false as a fhirIcons props should render a placeholder', () => {
22
+ const defaultProps = {
23
+ fhirResource: example,
24
+ fhirIcons: false,
25
+ };
26
+
27
+ const { getByTestId } = render(<MedicationOrder {...defaultProps} />);
28
+ const headerIcon = getByTestId('placeholder');
29
+
30
+ expect(headerIcon).toBeTruthy();
31
+ });
32
+
33
+ it('component with the img as a fhirIcons props should render an img', () => {
34
+ const defaultProps = {
35
+ fhirResource: example,
36
+ fhirIcons: (
37
+ <img
38
+ src={require('../assets/containers/MedicationOrder/medication-order.svg')}
39
+ alt="medication order"
40
+ />
41
+ ),
42
+ };
43
+
44
+ const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
45
+ const headerIcon = getByAltText('medication order');
46
+
47
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
48
+ });
49
+
50
+ it('component with the resources object as a fhirIcons props should render an img', () => {
51
+ const defaultProps = {
52
+ fhirResource: example,
53
+ fhirIcons: fhirIcons,
54
+ };
55
+
56
+ const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
57
+ const headerIcon = getByAltText('medication order');
58
+
59
+ expect(headerIcon.getAttribute('src')).toContain('IMAGE_MOCK');
60
+ });
61
+
62
+ it('component with the url as a fhirIcons props should render an img', () => {
63
+ const avatarSrc =
64
+ 'https://www.gravatar.com/avatar/?s=50&r=any&default=identicon&forcedefault=1';
65
+ const defaultProps = {
66
+ fhirResource: example,
67
+ fhirIcons: avatarSrc,
68
+ };
69
+
70
+ const { getByAltText } = render(<MedicationOrder {...defaultProps} />);
71
+ const headerIcon = getByAltText('header icon');
72
+
73
+ expect(headerIcon.getAttribute('src')).toContain(avatarSrc);
74
+ });
75
+
9
76
  it('should render with DSTU2 source data', () => {
10
77
  const defaultProps = {
11
78
  fhirResource: example,
@@ -9,9 +9,7 @@ import Date from '../../datatypes/Date';
9
9
 
10
10
  import { Root, Header, Body } from '../../ui';
11
11
 
12
- const MedicationRequest = props => {
13
- const { fhirResource, fhirIcons } = props;
14
- const headerIcon = fhirIcons && fhirIcons['Medication'];
12
+ const MedicationRequest = ({ fhirResource, fhirIcons }) => {
15
13
  const medicationReference = _get(fhirResource, 'medicationReference');
16
14
  const medicationCodeableConcept = _get(
17
15
  fhirResource,
@@ -77,7 +75,7 @@ const MedicationRequest = props => {
77
75
  <Accordion
78
76
  headerContent={
79
77
  <Header
80
- icon={headerIcon}
78
+ icon={fhirIcons}
81
79
  resourceName="MedicationRequest"
82
80
  title={
83
81
  medicationReference ? (
@@ -9,6 +9,7 @@ import R4Example1 from '../../../fixtures/r4/resources/medicationRequest/example
9
9
  import R4Example2 from '../../../fixtures/r4/resources/medicationRequest/example2.json';
10
10
  import R4Example3 from '../../../fixtures/r4/resources/medicationRequest/example3.json';
11
11
  import fhirIcons from '../../../fixtures/example-icons';
12
+ import MedicationRequestIcon from '../../../assets/containers/MedicationRequest/medication-request.svg';
12
13
 
13
14
  export default {
14
15
  title: 'MedicationRequest',
@@ -17,14 +18,20 @@ export default {
17
18
  export const DefaultVisualizationSTU3 = () => {
18
19
  const fhirResource = object('Resource', stu3Example1);
19
20
  return (
20
- <MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
21
+ <MedicationRequest
22
+ fhirResource={fhirResource}
23
+ fhirIcons={require('../../../assets/containers/MedicationRequest/medication-request.svg')}
24
+ />
21
25
  );
22
26
  };
23
27
 
24
28
  export const Example2OfSTU3 = () => {
25
29
  const fhirResource = object('Resource', stu3Example2);
26
30
  return (
27
- <MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
31
+ <MedicationRequest
32
+ fhirResource={fhirResource}
33
+ fhirIcons={MedicationRequestIcon}
34
+ />
28
35
  );
29
36
  };
30
37
 
@@ -37,14 +44,12 @@ export const Example1OfR4 = () => {
37
44
 
38
45
  export const Example2OfR4 = () => {
39
46
  const fhirResource = object('Resource', R4Example2);
40
- return (
41
- <MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
42
- );
47
+ return <MedicationRequest fhirResource={fhirResource} fhirIcons={false} />;
43
48
  };
44
49
 
45
50
  export const Example3OfR4 = () => {
46
51
  const fhirResource = object('Resource', R4Example3);
47
52
  return (
48
- <MedicationRequest fhirResource={fhirResource} fhirIcons={fhirIcons} />
53
+ <MedicationRequest fhirResource={fhirResource} fhirIcons={'random text'} />
49
54
  );
50
55
  };