@@ -9,6 +9,7 @@ import * as enterHandle from '@data-driven-forms/common/src/wizard/enter-handler
9
9
10
10
import { componentMapper , FormTemplate } from '../../index' ;
11
11
import reducer from '../../files/wizard/reducer' ;
12
+ import commonReducer from '@data-driven-forms/common/src/wizard/reducer' ;
12
13
import WizardToggle from '../../files/wizard/wizard-toggle' ;
13
14
14
15
describe ( '<Wizard />' , ( ) => {
@@ -1874,5 +1875,64 @@ describe('<Wizard />', () => {
1874
1875
const initialState = { openNav : false } ;
1875
1876
expect ( reducer ( initialState , { type : 'openNav' } ) ) . toEqual ( { openNav : true } ) ;
1876
1877
} ) ;
1878
+
1879
+ it ( 'common reducer - correctly assigns substepOf title when node' , ( ) => {
1880
+ const initialState = { } ;
1881
+ const formOptions = { getState : ( ) => ( { } ) } ;
1882
+ const customTitle = < span > Custom title</ span > ;
1883
+ const fields = [
1884
+ {
1885
+ name : 'security' ,
1886
+ title : 'Security' ,
1887
+ nextStep : 'credentials' ,
1888
+ substepOf : { name : 'Configuration' , title : customTitle } ,
1889
+ fields : [ ]
1890
+ } ,
1891
+ {
1892
+ name : 'credentials' ,
1893
+ title : 'Credentials' ,
1894
+ nextStep : 'summary' ,
1895
+ substepOf : 'Configuration' ,
1896
+ fields : [ ]
1897
+ } ,
1898
+ {
1899
+ name : 'summary' ,
1900
+ title : 'Summary' ,
1901
+ nextStep : 'pepa-step' ,
1902
+ fields : [ ]
1903
+ } ,
1904
+ {
1905
+ name : 'pepa-step' ,
1906
+ nextStep : 'pepa-step-2' ,
1907
+ title : 'title' ,
1908
+ substepOf : { name : 'pepa' , title : 'pepa-title' } ,
1909
+ fields : [ ]
1910
+ } ,
1911
+ {
1912
+ name : 'pepa-step-2' ,
1913
+ title : 'title 2' ,
1914
+ fields : [ ] ,
1915
+ substepOf : 'pepa'
1916
+ }
1917
+ ] ;
1918
+
1919
+ expect ( commonReducer ( initialState , { type : 'finishLoading' , payload : { formOptions, fields } } ) ) . toEqual ( {
1920
+ loading : false ,
1921
+ navSchema : [
1922
+ { index : 0 , name : 'security' , primary : true , substepOf : 'Configuration' , substepOfTitle : customTitle , title : 'Security' } ,
1923
+ {
1924
+ index : 1 ,
1925
+ name : 'credentials' ,
1926
+ primary : false ,
1927
+ substepOf : 'Configuration' ,
1928
+ substepOfTitle : customTitle ,
1929
+ title : 'Credentials'
1930
+ } ,
1931
+ { index : 2 , name : 'summary' , primary : true , substepOf : undefined , substepOfTitle : undefined , title : 'Summary' } ,
1932
+ { index : 3 , name : 'pepa-step' , primary : true , substepOf : 'pepa' , substepOfTitle : 'pepa-title' , title : 'title' } ,
1933
+ { index : 4 , name : 'pepa-step-2' , primary : false , substepOf : 'pepa' , substepOfTitle : 'pepa-title' , title : 'title 2' }
1934
+ ]
1935
+ } ) ;
1936
+ } ) ;
1877
1937
} ) ;
1878
1938
} ) ;
0 commit comments