@@ -8,15 +8,16 @@ import { similarPatientTreatmentsData, similarPatientTreatments } from './mock-d
8
8
9
9
Enzyme . configure ( { adapter : new Adapter ( ) } ) ;
10
10
11
- describe . only ( " TreatmentOptionsOutcome" , ( ) => {
11
+ describe ( ' TreatmentOptionsOutcome' , ( ) => {
12
12
let props , optionsOutcome ;
13
13
14
- const timescale = [ "1" , "3" , "5" ] ;
15
14
beforeEach ( ( ) => {
16
15
props = {
16
+ selectedTreatment : null ,
17
+ setSelectedTreatment : ( ) => { } ,
17
18
similarPatientTreatmentsData,
18
19
similarPatientTreatments,
19
- timescale
20
+ timescale : [ '1' , '3' , '5' ]
20
21
} ;
21
22
optionsOutcome = null ;
22
23
} ) ;
@@ -26,24 +27,24 @@ describe.only("TreatmentOptionsOutcome", () => {
26
27
return optionsOutcome ;
27
28
} ;
28
29
29
- describe . only ( " outcomes table: treatments" , ( ) => {
30
- it ( " renders the ' chemotherapy, ' hormonal therapy' , and ' test therapy' treatment rows" , ( ) => {
30
+ describe ( ' outcomes table: initial treatments' , ( ) => {
31
+ it ( ' renders the chemotherapy, hormonal therapy, and test therapy treatment rows' , ( ) => {
31
32
const tableRows = outcome ( ) . find ( '.treatment-options-outcomes-table__table .table-row' ) ;
32
33
expect ( tableRows ) . to . have . lengthOf ( 3 ) ;
33
34
expect ( tableRows . at ( 0 ) . find ( '.treatment-name' ) . text ( ) ) . to . eql ( 'test therapy' ) ;
34
35
expect ( tableRows . at ( 1 ) . find ( '.treatment-name' ) . text ( ) ) . to . eql ( 'chemotherapy' ) ;
35
36
expect ( tableRows . at ( 2 ) . find ( '.treatment-name' ) . text ( ) ) . to . eql ( 'hormonal therapy' ) ;
36
37
} ) ;
37
38
38
- it ( " renders the total number of patients" , ( ) => {
39
+ it ( ' renders the total number of patients' , ( ) => {
39
40
const tableRows = outcome ( ) . find ( '.treatment-options-outcomes-table__table .table-row' ) ;
40
41
expect ( tableRows ) . to . have . lengthOf ( 3 ) ;
41
42
expect ( tableRows . at ( 0 ) . find ( '.total-patients' ) . text ( ) ) . to . eql ( '(100)' ) ;
42
43
expect ( tableRows . at ( 1 ) . find ( '.total-patients' ) . text ( ) ) . to . eql ( '(82)' ) ;
43
44
expect ( tableRows . at ( 2 ) . find ( '.total-patients' ) . text ( ) ) . to . eql ( '(12)' ) ;
44
45
} ) ;
45
46
46
- it ( " calculates the correct one, three, and five survival rates" , ( ) => {
47
+ it ( ' calculates the correct one, three, and five survival rates' , ( ) => {
47
48
const tableRows = outcome ( ) . find ( '.treatment-options-outcomes-table__table .table-row' ) ;
48
49
expect ( tableRows ) . to . have . lengthOf ( 3 ) ;
49
50
@@ -69,7 +70,7 @@ describe.only("TreatmentOptionsOutcome", () => {
69
70
expect ( barChartText3 . at ( 2 ) . text ( ) ) . to . eql ( '91%' ) ;
70
71
} ) ;
71
72
72
- it ( " displays the top two side effects" , ( ) => {
73
+ it ( ' displays the top two side effects' , ( ) => {
73
74
const tableRows = outcome ( ) . find ( '.treatment-options-outcomes-table__table .table-row' ) ;
74
75
expect ( tableRows ) . to . have . lengthOf ( 3 ) ;
75
76
@@ -89,53 +90,7 @@ describe.only("TreatmentOptionsOutcome", () => {
89
90
expect ( sideEffectText3 . at ( 1 ) . text ( ) ) . to . eql ( 'fatigue (70%)' ) ;
90
91
} ) ;
91
92
92
- // it("hormonal therapy: calculates the correct one, three, and five survival rates with comparisons", () => {
93
- // const treatmentRows = outcome().find('.compared-treatments .table-row');
94
-
95
- // const barChartTexts = treatmentRows.at(1).find('.bar-chart-text');
96
-
97
- // expect(barChartTexts).to.have.lengthOf(6);
98
-
99
- // // 1 year and 1 year difference (83% / +23%)
100
- // expect(barChartTexts.at(0).text()).to.eql('83%');
101
- // expect(barChartTexts.at(1).text()).to.eql('23%');
102
- // expect(barChartTexts.at(1).find('span').hasClass('fa-caret-up')).to.eql(true);
103
-
104
- // // 3 year and 3 year difference (66% / +26%)
105
- // expect(barChartTexts.at(2).text()).to.eql('66%');
106
- // expect(barChartTexts.at(3).text()).to.eql('26%');
107
- // expect(barChartTexts.at(3).find('span').hasClass('fa-caret-up')).to.eql(true);
108
-
109
- // // 5 year and 5 year difference (16% / -4%)
110
- // expect(barChartTexts.at(4).text()).to.eql('16%');
111
- // expect(barChartTexts.at(5).text()).to.eql('4%');
112
- // expect(barChartTexts.at(5).find('span').hasClass('fa-caret-down')).to.eql(true);
113
- // });
114
-
115
- // it("chemotherapy: calculates the correct one, three, and five survival rates with comparisons", () => {
116
- // const treatmentRows = outcome().find('.compared-treatments .table-row');
117
-
118
- // const barChartTexts = treatmentRows.at(0).find('.bar-chart-text');
119
-
120
- // expect(barChartTexts).to.have.lengthOf(6);
121
-
122
- // // 1 year and 1 year difference (100% / +40%)
123
- // expect(barChartTexts.at(0).text()).to.eql('100%');
124
- // expect(barChartTexts.at(1).text()).to.eql('40%');
125
- // expect(barChartTexts.at(1).find('span').hasClass('fa-caret-up')).to.eql(true);
126
-
127
- // // 3 year and 3 year difference (100% / +60%)
128
- // expect(barChartTexts.at(2).text()).to.eql('100%');
129
- // expect(barChartTexts.at(3).text()).to.eql('60%');
130
- // expect(barChartTexts.at(3).find('span').hasClass('fa-caret-up')).to.eql(true);
131
-
132
- // // 5 year and 5 year difference (70% / +50%)
133
- // expect(barChartTexts.at(4).text()).to.eql('70%');
134
- // expect(barChartTexts.at(5).text()).to.eql('50%');
135
- // expect(barChartTexts.at(5).find('span').hasClass('fa-caret-up')).to.eql(true);
136
- // });
137
-
138
- it ( "sorts rows based on survival" , ( ) => {
93
+ it ( 'sorts rows based on survival' , ( ) => {
139
94
const header = outcome ( ) . find ( '.header-space' ) ;
140
95
let treatmentRows = outcome ( ) . find ( '.treatment-options-outcomes-table__table .table-row' ) ;
141
96
@@ -175,6 +130,58 @@ describe.only("TreatmentOptionsOutcome", () => {
175
130
expect ( treatmentRows . at ( 0 ) . find ( '.treatment-name' ) . text ( ) ) . to . eql ( 'chemotherapy' ) ;
176
131
expect ( treatmentRows . at ( 1 ) . find ( '.treatment-name' ) . text ( ) ) . to . eql ( 'hormonal therapy' ) ;
177
132
expect ( treatmentRows . at ( 2 ) . find ( '.treatment-name' ) . text ( ) ) . to . eql ( 'test therapy' ) ;
178
- } )
133
+ } ) ;
134
+ } ) ;
135
+
136
+ describe ( 'outcomes table: comparing treatments' , ( ) => {
137
+ it ( 'selects a treament when compared icon is clicked' , ( ) => {
138
+ props = {
139
+ ...props ,
140
+ setSelectedTreatment : jest . fn ( )
141
+ } ;
142
+
143
+ const compareIcons = outcome ( ) . find ( '.treatment-options-outcomes-table__table .compare-icon' ) ;
144
+ let treatmentRows = outcome ( ) . find ( '.treatment-options-outcomes-table__table .table-row' ) ;
145
+
146
+ expect ( treatmentRows . at ( 0 ) . find ( '.treatment-name' ) . text ( ) ) . to . eql ( 'test therapy' ) ;
147
+ expect ( treatmentRows . at ( 1 ) . find ( '.treatment-name' ) . text ( ) ) . to . eql ( 'chemotherapy' ) ;
148
+ expect ( treatmentRows . at ( 2 ) . find ( '.treatment-name' ) . text ( ) ) . to . eql ( 'hormonal therapy' ) ;
149
+
150
+ // select chemotherapy
151
+ compareIcons . at ( 1 ) . simulate ( 'click' ) ;
152
+
153
+ const [ callArgs ] = props . setSelectedTreatment . mock . calls ;
154
+ const [ treatment ] = callArgs ;
155
+
156
+ expect ( treatment . displayName ) . to . eql ( 'chemotherapy' ) ;
157
+ } ) ;
158
+
159
+ it ( 'hormonal therapy: calculates the correct one, three, and five survival rates with comparisons' , ( ) => {
160
+ props = {
161
+ ...props ,
162
+ selectedTreatment : similarPatientTreatmentsData [ 0 ]
163
+ } ;
164
+
165
+ let treatmentRows = outcome ( ) . find ( '.treatment-options-outcomes-table__table .table-row' ) ;
166
+
167
+ const barChartTexts = treatmentRows . at ( 1 ) . find ( '.bar-chart-text' ) ;
168
+
169
+ expect ( barChartTexts ) . to . have . lengthOf ( 6 ) ;
170
+
171
+ // 1 year and 1 year difference (98% / +2%)
172
+ expect ( barChartTexts . at ( 0 ) . text ( ) ) . to . eql ( '98%' ) ;
173
+ expect ( barChartTexts . at ( 1 ) . text ( ) ) . to . eql ( '2%' ) ;
174
+ expect ( barChartTexts . at ( 1 ) . find ( 'span' ) . hasClass ( 'fa-caret-up' ) ) . to . eql ( true ) ;
175
+
176
+ // 3 year and 3 year difference (92% / +1%)
177
+ expect ( barChartTexts . at ( 2 ) . text ( ) ) . to . eql ( '92%' ) ;
178
+ expect ( barChartTexts . at ( 3 ) . text ( ) ) . to . eql ( '1%' ) ;
179
+ expect ( barChartTexts . at ( 3 ) . find ( 'span' ) . hasClass ( 'fa-caret-up' ) ) . to . eql ( true ) ;
180
+
181
+ // 5 year and 5 year difference (87% / -4%)
182
+ expect ( barChartTexts . at ( 4 ) . text ( ) ) . to . eql ( '87%' ) ;
183
+ expect ( barChartTexts . at ( 5 ) . text ( ) ) . to . eql ( '4%' ) ;
184
+ expect ( barChartTexts . at ( 5 ) . find ( 'span' ) . hasClass ( 'fa-caret-down' ) ) . to . eql ( true ) ;
185
+ } ) ;
179
186
} ) ;
180
187
} ) ;
0 commit comments