@@ -1870,6 +1870,107 @@ export default function getDefaultFormStateTest(testValidator: TestValidatorType
18701870 } ) ;
18711871 } ) ;
18721872
1873+ describe ( 'array with nested dependent fixed-length array schema' , ( ) => {
1874+ const schema : RJSFSchema = {
1875+ items : [
1876+ {
1877+ dependencies : {
1878+ checkbox : {
1879+ if : {
1880+ properties : {
1881+ checkbox : {
1882+ const : true ,
1883+ } ,
1884+ } ,
1885+ } ,
1886+ then : {
1887+ properties : {
1888+ inner_array : {
1889+ items : [
1890+ {
1891+ title : 'Fixed Item' ,
1892+ type : 'string' ,
1893+ } ,
1894+ ] ,
1895+ title : 'Inner Fixed-Length Array' ,
1896+ type : 'array' ,
1897+ } ,
1898+ } ,
1899+ } ,
1900+ } ,
1901+ } ,
1902+ properties : {
1903+ checkbox : {
1904+ title : 'Dependency Checkbox' ,
1905+ type : 'boolean' ,
1906+ } ,
1907+ } ,
1908+ title : 'Outer Item' ,
1909+ type : 'object' ,
1910+ } ,
1911+ ] ,
1912+ title : 'Outer Fixed Length Array' ,
1913+ type : 'array' ,
1914+ } ;
1915+ const formData = [ { checkbox : true } ] ;
1916+ const includeUndefinedValues = 'excludeObjectChildren' ;
1917+ const expected = [
1918+ {
1919+ checkbox : true ,
1920+ inner_array : [ undefined ] ,
1921+ } ,
1922+ ] ;
1923+
1924+ test ( 'getDefaultFormState' , ( ) => {
1925+ expect ( getDefaultFormState ( testValidator , schema , formData , undefined , includeUndefinedValues ) ) . toEqual (
1926+ expected ,
1927+ ) ;
1928+ } ) ;
1929+
1930+ test ( 'computeDefaults' , ( ) => {
1931+ expect (
1932+ computeDefaults ( testValidator , schema , {
1933+ rawFormData : formData ,
1934+ includeUndefinedValues,
1935+ shouldMergeDefaultsIntoFormData : true ,
1936+ } ) ,
1937+ ) . toEqual ( expected ) ;
1938+ } ) ;
1939+
1940+ test ( 'getDefaultBasedOnSchemaType' , ( ) => {
1941+ expect (
1942+ getDefaultBasedOnSchemaType (
1943+ testValidator ,
1944+ schema ,
1945+ {
1946+ includeUndefinedValues,
1947+ } ,
1948+ [
1949+ {
1950+ checkbox : true ,
1951+ } ,
1952+ ] ,
1953+ ) ,
1954+ ) . toEqual ( expected ) ;
1955+ } ) ;
1956+
1957+ test ( 'getArrayDefaults' , ( ) => {
1958+ expect (
1959+ getArrayDefaults (
1960+ testValidator ,
1961+ schema ,
1962+ {
1963+ includeUndefinedValues,
1964+ } ,
1965+ [
1966+ {
1967+ checkbox : true ,
1968+ } ,
1969+ ] ,
1970+ ) ,
1971+ ) . toEqual ( expected ) ;
1972+ } ) ;
1973+ } ) ;
18731974 describe ( 'an invalid array schema' , ( ) => {
18741975 const schema : RJSFSchema = {
18751976 type : 'array' ,
0 commit comments