|
| 1 | +import {NgsgStoreService} from './ngsg-store.service'; |
| 2 | +import {NgsgDragelement} from './ngsg-dragelement.model'; |
| 3 | + |
| 4 | +describe('NgsgStoreService', () => { |
| 5 | + |
| 6 | + let sut: NgsgStoreService; |
| 7 | + |
| 8 | + beforeEach(() => { |
| 9 | + sut = new NgsgStoreService(); |
| 10 | + }); |
| 11 | + |
| 12 | + describe('InitState', () => { |
| 13 | + |
| 14 | + it('should add the items to the group', () => { |
| 15 | + const group = 'testgroup'; |
| 16 | + const items = ['Item1', 'Item2']; |
| 17 | + const classes = []; |
| 18 | + |
| 19 | + sut.initState(group, items, classes); |
| 20 | + expect(sut.getItems(group)).toEqual(items); |
| 21 | + }); |
| 22 | + |
| 23 | + it('should add empty items to the group if we do not pass items in', () => { |
| 24 | + const group = 'testgroup'; |
| 25 | + const items = undefined; |
| 26 | + const classes = []; |
| 27 | + |
| 28 | + sut.initState(group, items, classes); |
| 29 | + expect(sut.getItems(group)).toEqual([]); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should add the classes to the group', () => { |
| 33 | + const group = 'testgroup'; |
| 34 | + const items = ['Item1', 'Item2']; |
| 35 | + const classes = ['Class1', 'Class2']; |
| 36 | + |
| 37 | + sut.initState(group, items, classes); |
| 38 | + expect(sut.getClasses(group)).toEqual(classes); |
| 39 | + }); |
| 40 | + }); |
| 41 | + |
| 42 | + it('should set the items and then return it', () => { |
| 43 | + const group = 'testGroup'; |
| 44 | + const items = ['ItemOne', 'ItemTwo']; |
| 45 | + sut.initState(group); |
| 46 | + |
| 47 | + sut.setItems(group, items); |
| 48 | + expect(sut.getItems(group)).toEqual(items); |
| 49 | + }); |
| 50 | + |
| 51 | + it('should set the selectedItems and then return it', () => { |
| 52 | + const group = 'testGroup'; |
| 53 | + const selectedItems = ['ItemOne', 'ItemTwo']; |
| 54 | + sut.initState(group); |
| 55 | + |
| 56 | + sut.setSelectedItems(group, selectedItems); |
| 57 | + expect(sut.getSelectedItems(group) as any).toEqual(selectedItems); |
| 58 | + }); |
| 59 | + |
| 60 | + it('should get the first selectedItem', () => { |
| 61 | + const group = 'testGroup'; |
| 62 | + const firstItem = 'ItemOne' as any; |
| 63 | + const selectedItems = [firstItem, 'ItemTwo'] as any[]; |
| 64 | + sut.initState(group); |
| 65 | + |
| 66 | + sut.setSelectedItems(group, selectedItems); |
| 67 | + expect(sut.getFirstSelectItem(group)).toEqual(firstItem); |
| 68 | + }); |
| 69 | + |
| 70 | +}); |
0 commit comments