-
-
Notifications
You must be signed in to change notification settings - Fork 139
/
single-value-selector-modal.component.spec.ts
52 lines (42 loc) · 1.48 KB
/
single-value-selector-modal.component.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { BsModalRef } from 'ngx-bootstrap';
import { SingleValueSelectorModalComponent } from './single-value-selector-modal.component';
import { SingleValueSelectorModule } from './single-value-selector.module';
describe('SingleValueSelectorModalComponent', () => {
let component: SingleValueSelectorModalComponent;
let fixture: ComponentFixture<SingleValueSelectorModalComponent>;
const value = 'myValue';
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [ SingleValueSelectorModule ],
providers: [
BsModalRef,
],
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(SingleValueSelectorModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should safely create without config', () => {
expect(component).toBeTruthy();
});
it('should properly handle config (if any)', () => {
component.value = value;
component.config = {
options: [
{ name: 'option1', value: 'some value' },
{ name: 'option2', value },
{ name: 'option3', value: 'some other value' },
]
};
component.ngOnInit();
expect(component.selected).toEqual([{ name: 'option2', value }]);
});
it('onSelect() should properly set the value', () => {
component.onSelect({ selected: [ { value }]});
expect(component.value).toEqual(value);
});
});