@@ -8,20 +8,20 @@ jest.mock('../config');
88describe ( 'getSlotOperations' , ( ) => {
99 it ( 'should return an empty array if no apps are configured' , ( ) => {
1010 ( getSiteConfig as jest . Mock ) . mockReturnValue ( { apps : [ ] } ) ;
11- const result = getSlotOperations ( 'test-slot.ui' ) ;
11+ const result = getSlotOperations ( [ 'test-slot.ui' ] ) ;
1212 expect ( result ) . toEqual ( [ ] ) ;
1313 } ) ;
1414
1515 it ( 'should return an empty array if no slots are present in apps' , ( ) => {
1616 ( getSiteConfig as jest . Mock ) . mockReturnValue ( { apps : [ { slots : [ ] } ] } ) ;
17- const result = getSlotOperations ( 'test-slot.ui' ) ;
17+ const result = getSlotOperations ( [ 'test-slot.ui' ] ) ;
1818 expect ( result ) . toEqual ( [ ] ) ;
1919 } ) ;
2020
2121 it ( 'should return an empty array if no matching slotId is found' , ( ) => {
2222 const mockSlots : SlotOperation [ ] = [ { slotId : 'other-slot.ui' , op : WidgetOperationTypes . APPEND , id : 'widget1' , element : '' } ] ;
2323 ( getSiteConfig as jest . Mock ) . mockReturnValue ( { apps : [ { slots : mockSlots } ] } ) ;
24- const result = getSlotOperations ( 'test-slot.ui' ) ;
24+ const result = getSlotOperations ( [ 'test-slot.ui' ] ) ;
2525 expect ( result ) . toEqual ( [ ] ) ;
2626 } ) ;
2727
@@ -32,7 +32,7 @@ describe('getSlotOperations', () => {
3232 { slotId : 'other-slot.ui' , op : WidgetOperationTypes . APPEND , id : 'widget3' , element : '' } ,
3333 ] ;
3434 ( getSiteConfig as jest . Mock ) . mockReturnValue ( { apps : [ { slots : mockSlots } ] } ) ;
35- const result = getSlotOperations ( 'test-slot.ui' ) ;
35+ const result = getSlotOperations ( [ 'test-slot.ui' ] ) ;
3636 expect ( result ) . toEqual ( [
3737 { slotId : 'test-slot.ui' , op : WidgetOperationTypes . APPEND , id : 'widget1' , element : '' } ,
3838 { slotId : 'test-slot.ui' , op : WidgetOperationTypes . APPEND , id : 'widget2' , element : '' } ,
@@ -55,10 +55,24 @@ describe('getSlotOperations', () => {
5555 }
5656 ]
5757 } ) ;
58- const result = getSlotOperations ( 'test-slot.ui' ) ;
58+ const result = getSlotOperations ( [ 'test-slot.ui' ] ) ;
5959 expect ( result ) . toEqual ( [
6060 { slotId : 'test-slot.ui' , op : WidgetOperationTypes . APPEND , id : 'widget1' , element : '' } ,
6161 { slotId : 'test-slot.ui' , op : WidgetOperationTypes . APPEND , id : 'widget2' , element : '' } ,
6262 ] ) ;
6363 } ) ;
64+
65+ it ( 'should return operations matching both the primary id and an alias id' , ( ) => {
66+ const mockSlots : SlotOperation [ ] = [
67+ { slotId : 'test-slot.ui' , op : WidgetOperationTypes . APPEND , id : 'widget1' , element : '' } ,
68+ { slotId : 'test-slot-alias.ui' , op : WidgetOperationTypes . APPEND , id : 'widget2' , element : '' } ,
69+ { slotId : 'other-slot.ui' , op : WidgetOperationTypes . APPEND , id : 'widget3' , element : '' } ,
70+ ] ;
71+ ( getSiteConfig as jest . Mock ) . mockReturnValue ( { apps : [ { slots : mockSlots } ] } ) ;
72+ const result = getSlotOperations ( [ 'test-slot.ui' , 'test-slot-alias.ui' ] ) ;
73+ expect ( result ) . toEqual ( [
74+ { slotId : 'test-slot.ui' , op : WidgetOperationTypes . APPEND , id : 'widget1' , element : '' } ,
75+ { slotId : 'test-slot-alias.ui' , op : WidgetOperationTypes . APPEND , id : 'widget2' , element : '' } ,
76+ ] ) ;
77+ } ) ;
6478} ) ;
0 commit comments