1 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { PopoverModule } from 'ngx-bootstrap';
5 import { configureTestBed } from '../../../../testing/unit-test-helper';
6 import { SelectBadgesComponent } from './select-badges.component';
8 describe('SelectBadgesComponent', () => {
9 let component: SelectBadgesComponent;
10 let fixture: ComponentFixture<SelectBadgesComponent>;
13 declarations: [SelectBadgesComponent],
14 imports: [PopoverModule.forRoot()]
18 fixture = TestBed.createComponent(SelectBadgesComponent);
19 component = fixture.componentInstance;
20 fixture.detectChanges();
23 it('should create', () => {
24 expect(component).toBeTruthy();
27 it('should add item', () => {
29 { name: 'option1', description: '', selected: false },
30 { name: 'option2', description: '', selected: false }
33 component.selectOption(component.options[1]);
34 expect(component.data).toEqual(['option2']);
37 it('should update selected', () => {
39 { name: 'option1', description: '', selected: false },
40 { name: 'option2', description: '', selected: false }
42 component.data = ['option2'];
43 component.ngOnChanges();
44 expect(component.options[0].selected).toBe(false);
45 expect(component.options[1].selected).toBe(true);
48 it('should remove item', () => {
50 { name: 'option1', description: '', selected: true },
51 { name: 'option2', description: '', selected: true }
53 component.data = ['option1', 'option2'];
54 component.removeItem('option1');
55 expect(component.data).toEqual(['option2']);