@@ -3,7 +3,6 @@ import { Provider } from 'react-redux';
33import {
44 render , act , fireEvent , cleanup ,
55} from '@testing-library/react' ;
6- import { renderToStaticMarkup } from 'react-dom/server' ;
76import {
87 afterEach , beforeEach , describe , expect , test , vi ,
98} from 'vitest' ;
@@ -300,25 +299,29 @@ afterEach(() => cleanup());
300299describe ( 'ResponseBlock' , ( ) => {
301300 test ( 'renders without error' , async ( ) => {
302301 const studyStore = await makeStudyStore ( ) ;
303- const html = renderToStaticMarkup ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "belowStimulus" /> ) ) ;
302+ const { container } = render ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "belowStimulus" /> ) ) ;
303+ const html = container . innerHTML ;
304304 expect ( html ) . toContain ( '<div' ) ;
305305 } ) ;
306306
307307 test ( 'renders ResponseSwitcher for response at matching location' , async ( ) => {
308308 const studyStore = await makeStudyStore ( ) ;
309- const html = renderToStaticMarkup ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "belowStimulus" /> ) ) ;
309+ const { container } = render ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "belowStimulus" /> ) ) ;
310+ const html = container . innerHTML ;
310311 expect ( html ) . toContain ( 'switcher-shortText' ) ;
311312 } ) ;
312313
313314 test ( 'shows NextButton when location matches nextButtonLocation' , async ( ) => {
314315 const studyStore = await makeStudyStore ( ) ;
315- const html = renderToStaticMarkup ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "belowStimulus" /> ) ) ;
316+ const { container } = render ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "belowStimulus" /> ) ) ;
317+ const html = container . innerHTML ;
316318 expect ( html ) . toContain ( 'Next' ) ;
317319 } ) ;
318320
319321 test ( 'omits NextButton when location does not match nextButtonLocation' , async ( ) => {
320322 const studyStore = await makeStudyStore ( ) ;
321- const html = renderToStaticMarkup ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "sidebar" /> ) ) ;
323+ const { container } = render ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "sidebar" /> ) ) ;
324+ const html = container . innerHTML ;
322325 expect ( html ) . not . toContain ( 'Next' ) ;
323326 } ) ;
324327
@@ -332,13 +335,15 @@ describe('ResponseBlock', () => {
332335 ] ,
333336 } as IndividualComponent ;
334337 const studyStore = await makeStudyStore ( ) ;
335- const html = renderToStaticMarkup ( withStore ( studyStore , < ResponseBlock config = { hiddenConfig } location = "belowStimulus" /> ) ) ;
338+ const { container } = render ( withStore ( studyStore , < ResponseBlock config = { hiddenConfig } location = "belowStimulus" /> ) ) ;
339+ const html = container . innerHTML ;
336340 expect ( html ) . not . toContain ( 'switcher-shortText' ) ;
337341 } ) ;
338342
339343 test ( 'renders with provided style prop without error' , async ( ) => {
340344 const studyStore = await makeStudyStore ( ) ;
341- const html = renderToStaticMarkup ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "belowStimulus" style = { { color : 'red' } } /> ) ) ;
345+ const { container } = render ( withStore ( studyStore , < ResponseBlock config = { baseConfig } location = "belowStimulus" style = { { color : 'red' } } /> ) ) ;
346+ const html = container . innerHTML ;
342347 expect ( html ) . toContain ( 'switcher-shortText' ) ;
343348 } ) ;
344349
@@ -348,7 +353,8 @@ describe('ResponseBlock', () => {
348353 nextButtonText : 'Submit' ,
349354 } as IndividualComponent ;
350355 const studyStore = await makeStudyStore ( ) ;
351- const html = renderToStaticMarkup ( withStore ( studyStore , < ResponseBlock config = { configWithText } location = "belowStimulus" /> ) ) ;
356+ const { container } = render ( withStore ( studyStore , < ResponseBlock config = { configWithText } location = "belowStimulus" /> ) ) ;
357+ const html = container . innerHTML ;
352358 expect ( html ) . toContain ( 'Submit' ) ;
353359 } ) ;
354360
@@ -359,7 +365,8 @@ describe('ResponseBlock', () => {
359365 correctAnswer : [ { id : 'q1' , answer : 'correct' } ] ,
360366 } as IndividualComponent ;
361367 const studyStore = await makeStudyStore ( ) ;
362- const html = renderToStaticMarkup ( withStore ( studyStore , < ResponseBlock config = { configWithFeedback } location = "belowStimulus" /> ) ) ;
368+ const { container } = render ( withStore ( studyStore , < ResponseBlock config = { configWithFeedback } location = "belowStimulus" /> ) ) ;
369+ const html = container . innerHTML ;
363370 expect ( html ) . toContain ( 'Check Answer' ) ;
364371 } ) ;
365372
@@ -369,7 +376,8 @@ describe('ResponseBlock', () => {
369376 response : [ { type : 'textOnly' , id : 'q1' , prompt : 'Read this.' } ] ,
370377 } as IndividualComponent ;
371378 const studyStore = await makeStudyStore ( ) ;
372- const html = renderToStaticMarkup ( withStore ( studyStore , < ResponseBlock config = { textOnlyConfig } location = "belowStimulus" /> ) ) ;
379+ const { container } = render ( withStore ( studyStore , < ResponseBlock config = { textOnlyConfig } location = "belowStimulus" /> ) ) ;
380+ const html = container . innerHTML ;
373381 expect ( html ) . toContain ( 'switcher-textOnly' ) ;
374382 } ) ;
375383
0 commit comments