aboutsummaryrefslogtreecommitdiffstats
path: root/src/angular/form-elements/dropdown/dropdown.component.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/angular/form-elements/dropdown/dropdown.component.spec.ts')
-rw-r--r--src/angular/form-elements/dropdown/dropdown.component.spec.ts71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/angular/form-elements/dropdown/dropdown.component.spec.ts b/src/angular/form-elements/dropdown/dropdown.component.spec.ts
new file mode 100644
index 0000000..1c0cb4d
--- /dev/null
+++ b/src/angular/form-elements/dropdown/dropdown.component.spec.ts
@@ -0,0 +1,71 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+import { DropDownComponent } from './dropdown.component';
+import { IDropDownOption, DropDownTypes } from "./dropdown-models";
+import { FormsModule } from "@angular/forms";
+import {SvgIconModule} from "../../svg-icon/svg-icon.module";
+
+
+const label:string = "DropDown example";
+const placeHolder:string = "Please choose option";
+const options:IDropDownOption[] = [
+ {
+ label:'First Option',
+ value: 'First Option'
+ },
+ {
+ label:'Second Option',
+ value: 'Second Option'
+ },
+ {
+ label:'Third Option',
+ value: 'Third Option'
+ }
+];
+
+describe('DropDown component', () => {
+ let fixture: ComponentFixture<DropDownComponent>;
+ let component: DropDownComponent;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ DropDownComponent ],
+ imports:[
+ FormsModule,
+ SvgIconModule
+ ]
+ }).compileComponents();
+ fixture = TestBed.createComponent(DropDownComponent);
+ component = fixture.componentInstance;
+
+ }));
+
+ beforeEach(()=>{
+ component.label = label;
+ component.placeHolder = placeHolder;
+ component.options = options;
+ component.type = DropDownTypes.Regular;
+ console.log('herer we got component', component)
+ fixture.detectChanges();
+ });
+
+ it('component should be created', () => {
+ expect(component).toBeTruthy();
+ });
+
+ it('component should export the selected value', () => {
+ const option = options[1];
+ component.selectOption(option);
+ fixture.detectChanges();
+ expect(component.selectedOption).toEqual(option);
+ });
+
+ it('component should have autocomplite', () => {
+ expect(component.options.length).toEqual(3);
+ component.type = DropDownTypes.Auto;
+ component.filterValue = 'testERrorotesttresadfadfasdfasf';
+ fixture.detectChanges();
+ component.filterOptions(component.filterValue);
+ expect(component.options.length).toEqual(0);
+ });
+
+});