@@ -8,6 +8,7 @@ import {NgsgReflectService} from './sort/reflection/ngsg-reflect.service';
88import { NgsgStoreService } from './store/ngsg-store.service' ;
99import { NgsgEventsService } from './shared/ngsg-events.service' ;
1010import { NgsgOrderChange } from './shared/ngsg-order-change.model' ;
11+ import { NgsgElementsHelper } from './helpers/element/ngsg-elements.helper' ;
1112
1213describe ( 'NgsgItemDirective' , ( ) => {
1314 let sut : NgsgItemDirective ;
@@ -22,6 +23,7 @@ describe('NgsgItemDirective', () => {
2223 const ngsgStore = createSpyObj < NgsgStoreService > ( 'ngsgStore' , [
2324 'initState' ,
2425 'hasSelectedItems' ,
26+ 'getSelectedItems' ,
2527 'resetSelectedItems' ,
2628 'hasGroup' ,
2729 'hasItems' ,
@@ -169,12 +171,26 @@ describe('NgsgItemDirective', () => {
169171
170172 it ( 'should call the selctionservice with the host if the event occured on the host' , ( ) => {
171173 const group = 'test-group' ;
174+ NgsgElementsHelper . findIndex = ( ) => 0 ;
175+ ngsgStore . getSelectedItems . and . returnValue ( [ ] ) ;
172176 sut . ngSortGridGroup = group ;
173177
174178 sut . clicked ( ) ;
175179 expect ( ngsgSelectionService . updateSelectedDragItem ) . toHaveBeenCalledWith ( group , elementRef . nativeElement , true ) ;
176180 } ) ;
177181
182+ it ( 'should call the selection service with false if the item is selected' , ( ) => {
183+ const originalIndex = 0 ;
184+ const group = 'test-group' ;
185+ const element = { originalIndex} ;
186+ NgsgElementsHelper . findIndex = ( ) => originalIndex ;
187+ ngsgStore . getSelectedItems . and . returnValue ( [ element ] ) ;
188+ sut . ngSortGridGroup = group ;
189+
190+ sut . clicked ( ) ;
191+ expect ( ngsgSelectionService . updateSelectedDragItem ) . toHaveBeenCalledWith ( group , elementRef . nativeElement , false ) ;
192+ } ) ;
193+
178194 it ( `should init the state with empty items if group has yet not been
179195 initialized and the currentValue is null` , ( ) => {
180196 const group = 'test-group' ;
0 commit comments