@@ -8,6 +8,7 @@ import { Calculator } from 'fqm-execution';
88import MeasureUpload from '../../../components/measure-upload/MeasureFileUpload' ;
99import { DetailedResult } from '../../../util/types' ;
1010import { RouterContext } from 'next/dist/shared/lib/router-context.shared-runtime' ;
11+ import { Suspense } from 'react' ;
1112
1213const MOCK_DETAILED_RESULT : DetailedResult = {
1314 patientId : '' ,
@@ -72,7 +73,7 @@ describe('PopulationCalculation', () => {
7273 expect ( showClauseCoverageButton ) . not . toBeInTheDocument ( ) ;
7374 } ) ;
7475
75- it ( 'should render Calculate Population Results button when measure bundle is present and at least one patient created' , ( ) => {
76+ it ( 'should render Calculate Population Results button when measure bundle is present and at least one patient created' , async ( ) => {
7677 const MockMB = getMockRecoilState ( measureBundleState , {
7778 fileName : 'testName' ,
7879 content : MOCK_BUNDLE ,
@@ -93,17 +94,29 @@ describe('PopulationCalculation', () => {
9394 }
9495 } ) ;
9596
96- render (
97- mantineRecoilWrap (
98- < >
99- < MockMB />
100- < MockPatients />
101- < RouterContext . Provider value = { createMockRouter ( { pathname : '/' } ) } >
102- < PopulationCalculation />
103- </ RouterContext . Provider >
104- </ >
105- )
106- ) ;
97+ jest . spyOn ( Calculator , 'calculateDataRequirements' ) . mockResolvedValue ( {
98+ results : {
99+ resourceType : 'Library' ,
100+ status : 'draft' ,
101+ type : { }
102+ }
103+ } ) ;
104+
105+ await act ( async ( ) => {
106+ render (
107+ mantineRecoilWrap (
108+ < >
109+ < MockMB />
110+ < MockPatients />
111+ < Suspense >
112+ < RouterContext . Provider value = { createMockRouter ( { pathname : '/' } ) } >
113+ < PopulationCalculation />
114+ </ RouterContext . Provider >
115+ </ Suspense >
116+ </ >
117+ )
118+ ) ;
119+ } ) ;
107120
108121 const calculateButton = screen . getByRole ( 'button' , { name : 'Calculate Population Results' } ) as HTMLButtonElement ;
109122 expect ( calculateButton ) . toBeInTheDocument ( ) ;
@@ -161,9 +174,11 @@ describe('PopulationCalculation', () => {
161174 < MockPatients />
162175 < MockMB />
163176 < MeasureUpload logError = { jest . fn ( ) } />
164- < RouterContext . Provider value = { createMockRouter ( { pathname : '/' } ) } >
165- < PopulationCalculation />
166- </ RouterContext . Provider >
177+ < Suspense >
178+ < RouterContext . Provider value = { createMockRouter ( { pathname : '/' } ) } >
179+ < PopulationCalculation />
180+ </ RouterContext . Provider >
181+ </ Suspense >
167182 </ >
168183 )
169184 ) ;
@@ -234,9 +249,11 @@ describe('PopulationCalculation', () => {
234249 < MockPatients />
235250 < MockMB />
236251 < MeasureUpload logError = { jest . fn ( ) } />
237- < RouterContext . Provider value = { createMockRouter ( { pathname : '/' } ) } >
238- < PopulationCalculation />
239- </ RouterContext . Provider >
252+ < Suspense >
253+ < RouterContext . Provider value = { createMockRouter ( { pathname : '/' } ) } >
254+ < PopulationCalculation />
255+ </ RouterContext . Provider >
256+ </ Suspense >
240257 </ >
241258 )
242259 ) ;
@@ -307,9 +324,11 @@ describe('PopulationCalculation', () => {
307324 < MockPatients />
308325 < MockMB />
309326 < MeasureUpload logError = { jest . fn ( ) } />
310- < RouterContext . Provider value = { createMockRouter ( { pathname : '/' } ) } >
311- < PopulationCalculation />
312- </ RouterContext . Provider >
327+ < Suspense >
328+ < RouterContext . Provider value = { createMockRouter ( { pathname : '/' } ) } >
329+ < PopulationCalculation />
330+ </ RouterContext . Provider >
331+ </ Suspense >
313332 </ >
314333 )
315334 ) ;
0 commit comments