@@ -24,6 +24,16 @@ const mockedComponents = [{
2424 color : null ,
2525 internal_tags_list : [ 'tag' ] ,
2626 internal_tag_ids : [ 1 ] ,
27+ } , {
28+ name : 'name-2' ,
29+ display_name : 'Name 2' ,
30+ created_at : '2021-08-09T12:00:00Z' ,
31+ updated_at : '2021-08-09T12:00:00Z' ,
32+ id : 12346 ,
33+ schema : { type : 'object' } ,
34+ color : null ,
35+ internal_tags_list : [ ] ,
36+ internal_tag_ids : [ ] ,
2737} ] ;
2838
2939const handlers = [
@@ -70,6 +80,16 @@ describe('pull components actions', () => {
7080 color : null ,
7181 internal_tags_list : [ 'tag' ] ,
7282 internal_tag_ids : [ 1 ] ,
83+ } , {
84+ name : 'name-2' ,
85+ display_name : 'Name 2' ,
86+ created_at : '2021-08-09T12:00:00Z' ,
87+ updated_at : '2021-08-09T12:00:00Z' ,
88+ id : 12346 ,
89+ schema : { type : 'object' } ,
90+ color : null ,
91+ internal_tags_list : [ ] ,
92+ internal_tag_ids : [ ] ,
7393 } ] ;
7494
7595 const result = await fetchComponents ( '12345' , 'valid-token' , 'eu' ) ;
@@ -94,6 +114,25 @@ describe('pull components actions', () => {
94114 expect ( result ) . toEqual ( mockResponse . components [ 0 ] ) ;
95115 } ) ;
96116
117+ it ( 'should choose the right component when multiple names match' , async ( ) => {
118+ const mockResponse = {
119+ components : [ {
120+ name : 'name-2' ,
121+ display_name : 'Name 2' ,
122+ created_at : '2021-08-09T12:00:00Z' ,
123+ updated_at : '2021-08-09T12:00:00Z' ,
124+ id : 12346 ,
125+ schema : { type : 'object' } ,
126+ color : null ,
127+ internal_tags_list : [ ] ,
128+ internal_tag_ids : [ ] ,
129+ } ] ,
130+ } ;
131+ // searching for 'name-2' would match both 'component-name-2' and 'name-2'
132+ const result = await fetchComponent ( '12345' , 'name-2' , 'valid-token' , 'eu' ) ;
133+ expect ( result ) . toEqual ( mockResponse . components [ 0 ] ) ;
134+ } ) ;
135+
97136 it ( 'should throw an masked error for invalid token' , async ( ) => {
98137 await expect ( fetchComponents ( '12345' , 'invalid-token' , 'eu' ) ) . rejects . toThrow (
99138 expect . objectContaining ( {
0 commit comments