@@ -8,8 +8,10 @@ import {NgsgElementsHelper} from './ngsg-elements.helper';
88
99describe ( 'NgsgSelectionService' , ( ) => {
1010
11- const ngsgClassService = createSpyObj < NgsgClassService > ( 'classService' , [ 'addSelectedClass' , 'addSelectedClass' ] ) ;
12- const ngsgStore = createSpyObj < NgsgStoreService > ( 'ngsgStore' , [ 'addSelectedItem' , 'hasSelectedItems' ] ) ;
11+ const ngsgClassService = createSpyObj < NgsgClassService > ( 'classService' ,
12+ [ 'addSelectedClass' , 'addSelectedClass' , 'removeSelectedClass' ] ) ;
13+ const ngsgStore = createSpyObj < NgsgStoreService > ( 'ngsgStore' ,
14+ [ 'addSelectedItem' , 'hasSelectedItems' , 'removeSelectedItem' ] ) ;
1315 let sut : NgsgSelectionService ;
1416
1517 beforeEach ( ( ) => {
@@ -77,6 +79,41 @@ describe('NgsgSelectionService', () => {
7779
7880 expect ( ngsgStore . addSelectedItem ) . toHaveBeenCalledWith ( group , { node : item , originalIndex : index } ) ;
7981 } ) ;
82+
83+ it ( 'should remove the selectedItem if the Meta key is pressed and the selected item is clicked' , ( ) => {
84+
85+ const event = new KeyboardEvent ( 'keydown' , {
86+ key : 'Meta'
87+ } ) ;
88+ const group = 'groupOne' ;
89+ const item = 'Some element' as any ;
90+ const selected = false ;
91+ const index = 2 ;
92+ NgsgElementsHelper . findIndex = ( ) => index ;
93+
94+ window . dispatchEvent ( event ) ;
95+ sut . updateSelectedDragItem ( group , item , selected ) ;
96+
97+ expect ( ngsgStore . removeSelectedItem ) . toHaveBeenCalledWith ( group , item ) ;
98+ } ) ;
99+
100+ it ( `should remove the selected class from the selected item if the Meta key is pressed
101+ and the selected item is clicked` , ( ) => {
102+
103+ const event = new KeyboardEvent ( 'keydown' , {
104+ key : 'Meta'
105+ } ) ;
106+ const group = 'groupOne' ;
107+ const item = 'Some element' as any ;
108+ const selected = false ;
109+ const index = 2 ;
110+ NgsgElementsHelper . findIndex = ( ) => index ;
111+
112+ window . dispatchEvent ( event ) ;
113+ sut . updateSelectedDragItem ( group , item , selected ) ;
114+
115+ expect ( ngsgClassService . removeSelectedClass ) . toHaveBeenCalledWith ( item ) ;
116+ } ) ;
80117 } ) ;
81118
82119 } ) ;
0 commit comments