]> git.apps.os.sepia.ceph.com Git - ceph.git/blob
52c3de2161cd30d8c7f9ac2332bd3a3b302fc6fe
[ceph.git] /
1 import { ComponentFixture, TestBed } from '@angular/core/testing';
2
3 import { PopoverModule } from 'ngx-bootstrap';
4
5 import { configureTestBed } from '../../../../testing/unit-test-helper';
6 import { SelectBadgesComponent } from './select-badges.component';
7
8 describe('SelectBadgesComponent', () => {
9   let component: SelectBadgesComponent;
10   let fixture: ComponentFixture<SelectBadgesComponent>;
11
12   configureTestBed({
13     declarations: [SelectBadgesComponent],
14     imports: [PopoverModule.forRoot()]
15   });
16
17   beforeEach(() => {
18     fixture = TestBed.createComponent(SelectBadgesComponent);
19     component = fixture.componentInstance;
20     fixture.detectChanges();
21   });
22
23   it('should create', () => {
24     expect(component).toBeTruthy();
25   });
26
27   it('should add item', () => {
28     component.options = [
29       {name: 'option1', description: '', selected: false},
30       {name: 'option2', description: '', selected: false}
31     ];
32     component.data = [];
33     component.selectOption(component.options[1]);
34     expect(component.data).toEqual(['option2']);
35   });
36
37   it('should update selected', () => {
38     component.options = [
39       {name: 'option1', description: '', selected: false},
40       {name: 'option2', description: '', selected: false}
41     ];
42     component.data = ['option2'];
43     component.ngOnChanges();
44     expect(component.options[0].selected).toBe(false);
45     expect(component.options[1].selected).toBe(true);
46   });
47
48   it('should remove item', () => {
49     component.options = [
50       {name: 'option1', description: '', selected: true},
51       {name: 'option2', description: '', selected: true}
52     ];
53     component.data = ['option1', 'option2'];
54     component.removeItem('option1');
55     expect(component.data).toEqual(['option2']);
56   });
57
58 });