@@ -8,8 +8,11 @@ import {
88} from 'src/graphql/types.generated' ;
99import { SalaryCalculationQuery } from '../../SalaryCalculatorContext/SalaryCalculation.generated' ;
1010import {
11+ EffectiveSalaryRequestMock ,
1112 SalaryCalculatorTestWrapper ,
1213 SalaryCalculatorTestWrapperProps ,
14+ hcmSpouseMock ,
15+ hcmUserMock ,
1316} from '../../SalaryCalculatorTestWrapper' ;
1417import { RequestedSalaryCard } from './RequestedSalaryCard' ;
1518
@@ -27,9 +30,19 @@ const defaultSalaryMock: DeepPartial<SalaryCalculationQuery['salaryRequest']> =
2730 } ,
2831 } ;
2932
30- const TestComponent : React . FC < SalaryCalculatorTestWrapperProps > = ( props ) => (
33+ const approvedSalaryMock : EffectiveSalaryRequestMock = {
34+ personNumber : hcmUserMock . staffInfo . personNumber ,
35+ salary : 11111 ,
36+ spouseSalary : 22222 ,
37+ } ;
38+
39+ const TestComponent : React . FC < SalaryCalculatorTestWrapperProps > = ( {
40+ effectiveSalaryRequestMock = approvedSalaryMock ,
41+ ...props
42+ } ) => (
3143 < SalaryCalculatorTestWrapper
3244 salaryRequestMock = { defaultSalaryMock }
45+ effectiveSalaryRequestMock = { effectiveSalaryRequestMock }
3346 hcmUser = { {
3447 currentSalary : { grossSalaryAmount : 10001 } ,
3548 } }
@@ -74,7 +87,7 @@ As you set your salary level, the amount you receive should reflect the amount o
7487 expect (
7588 getAllByRole ( 'rowheader' ) . map ( ( cell ) => cell . textContent ) ,
7689 ) . toEqual ( [
77- 'Current Salary' ,
90+ 'Current Requested Salary' ,
7891 'Minimum Salary' ,
7992 'Maximum Allowable Salary (CAP)' ,
8093 'Requested Salary' ,
@@ -86,7 +99,27 @@ As you set your salary level, the amount you receive should reflect the amount o
8699 const { getAllByRole } = render ( < TestComponent /> ) ;
87100
88101 const expectedCells = [
89- [ '$10,001.00' , '$20,001.00' ] ,
102+ [ '$11,111.00' , '$22,222.00' ] ,
103+ [ '$10,003.00' , '$20,003.00' ] ,
104+ [ '$10,004.00' , '$20,004.00' ] ,
105+ ] . flat ( ) ;
106+
107+ await waitFor ( ( ) =>
108+ expect (
109+ getAllByRole ( 'cell' )
110+ . slice ( 0 , - 2 )
111+ . map ( ( cell ) => cell . textContent ) ,
112+ ) . toEqual ( expectedCells ) ,
113+ ) ;
114+ } ) ;
115+
116+ it ( 'should render a dash when there is no approved salary request' , async ( ) => {
117+ const { getAllByRole } = render (
118+ < TestComponent effectiveSalaryRequestMock = { null } /> ,
119+ ) ;
120+
121+ const expectedCells = [
122+ [ '–' , '–' ] ,
90123 [ '$10,003.00' , '$20,003.00' ] ,
91124 [ '$10,004.00' , '$20,004.00' ] ,
92125 ] . flat ( ) ;
@@ -101,6 +134,31 @@ As you set your salary level, the amount you receive should reflect the amount o
101134 ) ;
102135 } ) ;
103136
137+ it ( 'swaps the requested salary when the spouse created the request' , async ( ) => {
138+ const { getAllByRole } = render (
139+ < TestComponent
140+ effectiveSalaryRequestMock = { {
141+ ...approvedSalaryMock ,
142+ personNumber : hcmSpouseMock . staffInfo . personNumber ,
143+ } }
144+ /> ,
145+ ) ;
146+
147+ await waitFor ( ( ) =>
148+ expect (
149+ getAllByRole ( 'cell' )
150+ . slice ( 0 , - 2 )
151+ . map ( ( cell ) => cell . textContent ) ,
152+ ) . toEqual (
153+ [
154+ [ '$22,222.00' , '$11,111.00' ] ,
155+ [ '$10,003.00' , '$20,003.00' ] ,
156+ [ '$10,004.00' , '$20,004.00' ] ,
157+ ] . flat ( ) ,
158+ ) ,
159+ ) ;
160+ } ) ;
161+
104162 it ( 'should render the effective paycheck note when payroll dates match' , async ( ) => {
105163 const { findByRole } = render (
106164 < TestComponent
@@ -148,7 +206,7 @@ As you set your salary level, the amount you receive should reflect the amount o
148206 expect (
149207 getAllByRole ( 'rowheader' ) . map ( ( cell ) => cell . textContent ) ,
150208 ) . toEqual ( [
151- 'Current Salary' ,
209+ 'Current Requested Salary' ,
152210 'Minimum Salary' ,
153211 'Maximum Allowable Salary (CAP)' ,
154212 'Requested Salary' ,
@@ -159,7 +217,23 @@ As you set your salary level, the amount you receive should reflect the amount o
159217 it ( 'should render table cells with formatted currency' , async ( ) => {
160218 const { getAllByRole } = render ( < TestComponent hasSpouse = { false } /> ) ;
161219
162- const expectedCells = [ '$10,001.00' , '$10,003.00' , '$10,004.00' ] ;
220+ const expectedCells = [ '$11,111.00' , '$10,003.00' , '$10,004.00' ] ;
221+
222+ await waitFor ( ( ) =>
223+ expect (
224+ getAllByRole ( 'cell' )
225+ . slice ( 0 , - 1 )
226+ . map ( ( cell ) => cell . textContent ) ,
227+ ) . toEqual ( expectedCells ) ,
228+ ) ;
229+ } ) ;
230+
231+ it ( 'should render a dash when there is no approved salary request' , async ( ) => {
232+ const { getAllByRole } = render (
233+ < TestComponent hasSpouse = { false } effectiveSalaryRequestMock = { null } /> ,
234+ ) ;
235+
236+ const expectedCells = [ '–' , '$10,003.00' , '$10,004.00' ] ;
163237
164238 await waitFor ( ( ) =>
165239 expect (
0 commit comments