Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should set value', async(async () => {
fixture.detectChanges();
const display = fixture.debugElement.query(By.css('.display'));
display.nativeElement.dispatchEvent(EventGenerator.click);
fixture.detectChanges();
const searchInput = fixture.debugElement.query(By.css('.mat-input-element')).nativeElement;
searchInput.value = randomString;
searchInput.dispatchEvent(EventGenerator.input());
fixture.detectChanges();
await fixture.whenStable();
const [query] = sourceSpy.calls.mostRecent().args;
expect(query).toBe(randomString);
const itemContainer = fixture.debugElement.query(By.css('.item-list-container'));
itemContainer.nativeElement.dispatchEvent(
EventGenerator.keyDown(Key.Enter),
);
fixture.detectChanges();
expect(uiSuggest.value[0].text).toBe(randomString);
}));
it('should clear value if the user presses the ENTER key on the clear button', () => {
const input = fixture.debugElement.query(By.css('input'));
input.nativeElement.value = value;
input.nativeElement.dispatchEvent(EventGenerator.input());
fixture.detectChanges();
expect(search.value).not.toEqual('');
const clear = fixture.debugElement.query(By.css('.ui-grid-search-cancel'));
clear.nativeElement.dispatchEvent(EventGenerator.keyUp(Key.Enter));
fixture.detectChanges();
expect(search.value).toEqual('');
});
});
const searchTerm = faker.random.word();
grid.header!.searchFilter
.pipe(
take(1),
finalize(done),
).subscribe(([filter]) => {
expect(filter.property).toEqual('myNumber');
expect(filter.value).toEqual(searchTerm);
});
const search = fixture.debugElement.query(By.css('ui-grid-search'));
const input = search.query(By.css('input'));
input.nativeElement.value = searchTerm;
input.nativeElement.dispatchEvent(EventGenerator.input());
fixture.detectChanges();
});
});