@@ -23,11 +23,17 @@ jest.mock("../../utils/reactflowUtils", () => ({
2323 } ) ,
2424} ) ) ;
2525
26+ jest . mock ( "../../utils/component-template-utils" , ( ) => ( {
27+ buildTemplatesByModule : jest . fn ( ( ) => ( { } ) ) ,
28+ } ) ) ;
29+
2630// Mock imports
2731const mockExtractSecretFieldsFromComponents =
2832 require ( "../../utils/reactflowUtils" ) . extractSecretFieldsFromComponents ;
2933const mockTemplatesGenerator =
3034 require ( "../../utils/reactflowUtils" ) . templatesGenerator ;
35+ const mockBuildTemplatesByModule =
36+ require ( "../../utils/component-template-utils" ) . buildTemplatesByModule ;
3137const mockTypesGenerator = require ( "../../utils/reactflowUtils" ) . typesGenerator ;
3238
3339const mockAPIData : APIDataType = {
@@ -85,13 +91,15 @@ describe("useTypesStore", () => {
8591 return new Set ( Object . keys ( data ) ) ;
8692 } ) ;
8793 mockTemplatesGenerator . mockReturnValue ( { } ) ;
94+ mockBuildTemplatesByModule . mockReturnValue ( { } ) ;
8895 mockTypesGenerator . mockReturnValue ( { } ) ;
8996
9097 act ( ( ) => {
9198 useTypesStore . setState ( {
9299 ComponentFields : new Set ( ) ,
93100 types : { } ,
94101 templates : { } ,
102+ templatesByModule : { } ,
95103 data : { } ,
96104 } ) ;
97105 } ) ;
@@ -104,6 +112,7 @@ describe("useTypesStore", () => {
104112 expect ( result . current . ComponentFields ) . toEqual ( new Set ( ) ) ;
105113 expect ( result . current . types ) . toEqual ( { } ) ;
106114 expect ( result . current . templates ) . toEqual ( { } ) ;
115+ expect ( result . current . templatesByModule ) . toEqual ( { } ) ;
107116 expect ( result . current . data ) . toEqual ( { } ) ;
108117 } ) ;
109118 } ) ;
@@ -209,6 +218,9 @@ describe("useTypesStore", () => {
209218 it ( "should set types, templates, data, and component fields" , ( ) => {
210219 mockTypesGenerator . mockReturnValue ( mockTypes ) ;
211220 mockTemplatesGenerator . mockReturnValue ( mockTemplates ) ;
221+ mockBuildTemplatesByModule . mockReturnValue ( {
222+ "module.text" : mockTemplates . TextInput ,
223+ } ) ;
212224 mockExtractSecretFieldsFromComponents . mockReturnValue (
213225 new Set ( [ "TextInput" , "NumberInput" ] ) ,
214226 ) ;
@@ -221,12 +233,16 @@ describe("useTypesStore", () => {
221233
222234 expect ( mockTypesGenerator ) . toHaveBeenCalledWith ( mockAPIData ) ;
223235 expect ( mockTemplatesGenerator ) . toHaveBeenCalledWith ( mockAPIData ) ;
236+ expect ( mockBuildTemplatesByModule ) . toHaveBeenCalledWith ( mockAPIData ) ;
224237 expect ( mockExtractSecretFieldsFromComponents ) . toHaveBeenCalledWith (
225238 mockAPIData ,
226239 ) ;
227240
228241 expect ( result . current . types ) . toEqual ( mockTypes ) ;
229242 expect ( result . current . templates ) . toEqual ( mockTemplates ) ;
243+ expect ( result . current . templatesByModule ) . toEqual ( {
244+ "module.text" : mockTemplates . TextInput ,
245+ } ) ;
230246 expect ( result . current . data ) . toEqual ( mockAPIData ) ;
231247 expect ( result . current . ComponentFields ) . toEqual (
232248 new Set ( [ "TextInput" , "NumberInput" ] ) ,
0 commit comments