@@ -31,14 +31,10 @@ import { HaapiStepperActionStep, HaapiStepperFormAction } from './haapi-stepper.
3131import type { BootstrapConfiguration } from '../../data-access/bootstrap-configuration' ;
3232
3333describe ( 'HaapiStepper' , ( ) => {
34- const initializationHref = 'https://example.com/auth' ;
3534 const initialStepType = HAAPI_STEPS . AUTHENTICATION ;
3635
3736 beforeEach ( ( ) => {
3837 vi . clearAllMocks ( ) ;
39- vi . stubGlobal ( 'location' , {
40- href : initializationHref ,
41- } ) ;
4238 mockHaapiFetchStep ( initialStepType ) ;
4339 } ) ;
4440
@@ -48,41 +44,20 @@ describe('HaapiStepper', () => {
4844 } ) ;
4945
5046 describe ( 'Steps' , ( ) => {
51- describe ( 'initialization' , ( ) => {
52- afterEach ( ( ) => {
53- delete mockConfiguration . initialUrl ;
54- } ) ;
55-
56- it ( 'should initialize the first step with the current location and render the children' , async ( ) => {
57- render (
58- < HaapiStepper >
59- < TestComponent />
60- </ HaapiStepper >
61- ) ;
62-
63- expect ( mockHaapiFetch ) . toHaveBeenCalledWith ( initializationHref , { method : 'GET' } ) ;
64-
65- const stepRendered = await screen . findByTestId ( 'step-type' ) ;
66-
67- expect ( stepRendered ) . toHaveTextContent ( initialStepType ) ;
68- expect ( screen . queryByTestId ( 'loading' ) ) . not . toBeInTheDocument ( ) ;
69- expect ( screen . queryByTestId ( 'error' ) ) . not . toBeInTheDocument ( ) ;
70- } ) ;
47+ it ( 'should initialize the first step with the bootstrap initial URL and render the children' , async ( ) => {
48+ render (
49+ < HaapiStepper >
50+ < TestComponent />
51+ </ HaapiStepper >
52+ ) ;
7153
72- it ( 'should initialize the first step with the bootstrap initial URL' , async ( ) => {
73- const initialUrl = 'https://example.com/other' ;
74- mockConfiguration . initialUrl = initialUrl ;
54+ expect ( mockHaapiFetch ) . toHaveBeenCalledWith ( mockConfiguration . initialUrl , { method : 'GET' } ) ;
7555
76- render (
77- < HaapiStepper >
78- < TestComponent />
79- </ HaapiStepper >
80- ) ;
56+ const stepRendered = await screen . findByTestId ( 'step-type' ) ;
8157
82- await waitFor ( ( ) => {
83- expect ( mockHaapiFetch ) . toHaveBeenCalledWith ( initialUrl , { method : 'GET' } ) ;
84- } ) ;
85- } ) ;
58+ expect ( stepRendered ) . toHaveTextContent ( initialStepType ) ;
59+ expect ( screen . queryByTestId ( 'loading' ) ) . not . toBeInTheDocument ( ) ;
60+ expect ( screen . queryByTestId ( 'error' ) ) . not . toBeInTheDocument ( ) ;
8661 } ) ;
8762
8863 it ( 'should go to the next step and provide the updated current step' , async ( ) => {
@@ -384,7 +359,7 @@ describe('HaapiStepper', () => {
384359 await goToNextStep ( HAAPI_STEPS . POLLING , { bankId : true } ) ;
385360
386361 const startButton = await screen . findByRole ( 'button' , { name : 'Start BankID' } ) ;
387-
362+
388363 act ( ( ) => startButton . click ( ) ) ;
389364
390365 await waitFor ( ( ) => {
@@ -502,8 +477,13 @@ describe('HaapiStepper', () => {
502477
503478 expect ( historyData ) . toHaveLength ( 1 ) ;
504479 expect ( historyData [ 0 ] . step . type ) . toBe ( initialStep ) ;
505- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
506- expect ( historyData [ 0 ] . triggeredByAction ) . toEqual ( { ...previousStepTriggerActionKind , id : expect . anything ( ) } ) ;
480+ expect ( historyData [ 0 ] . triggeredByAction ) . toEqual ( {
481+ ...previousStepTriggerActionKind ,
482+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
483+ id : expect . anything ( ) ,
484+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
485+ href : expect . anything ( ) ,
486+ } ) ;
507487 expect ( historyData [ 0 ] . triggeredByPayload ) . toBeUndefined ( ) ;
508488
509489 await goToNextStep ( secondStep ) ;
@@ -659,7 +639,9 @@ vi.mock('../../data-access/haapi-fetch-initializer', () => {
659639} ) ;
660640
661641const mockConfiguration : Partial < BootstrapConfiguration > = vi . hoisted ( ( ) => {
662- return { } ;
642+ return {
643+ initialUrl : 'https://example.com/auth' ,
644+ } ;
663645} ) ;
664646vi . mock ( '../../data-access/bootstrap-configuration' , ( ) => {
665647 return {
0 commit comments