hello, I have a method called
onShowList()
and I want to write a unit test case for it, I am a beginner with writing a test cases so please help
public onShowList(): void {
this.showList = !this.showList;
if (this.showList) {
this.calcListPosition();
this.showListOverlay();
if (this.searchable) {
setTimeout(() => {
this.searchFilter.nativeElement.value = '';
this.searchFilter.nativeElement.focus()
}
, 0);
}
}
}
What I have tried:
I have a spec file, and I tried to call this method by writing this code
fdescribe('DropDownComponent', () => {
let component: DropDownComponent;
let fixture: ComponentFixture<DropDownComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ DropDownComponent ],
imports: [
CoreTranslationModule.forRoot(),
HttpClientTestingModule
]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(DropDownComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
console.log(123456,component.onShowList())
expect(component.onShowList()).toBe();
});
what code should I write next to test this component