Hello there, currently I am working on an application using Angular and TypeScript.
Here is a snippet of my template code:
<input type="text" placeholder="Search Results" (input)="searchInput($event)">
And here is the TypeScript code for the searchInput method :
searchInput(event: Event & { target: HTMLInputElement}) {
const { value } = event.target;
this.value = value;
// calling another method to reset values
}
I am now trying to figure out how to write input test cases in my spec.ts file.
describe('Component', () => {
let component: Component;
let fixture: ComponentFixture<Component>;
const event = Event; // Is this correct ?
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
AppModule
],
providers: [
]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(Component);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('test case for searchInput() ', () => {
// what would be the best approach here?
});
});
I would appreciate any guidance on how to go about writing these test cases. Thank you!