Skip to content

Commit

Permalink
fixed Unit Tests Need to Improvement #8025
Browse files Browse the repository at this point in the history
  • Loading branch information
yigitfindikli committed Aug 21, 2019
1 parent a550abe commit 2ddae69
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/app/components/keyfilter/keyfilter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,30 @@ describe('KeyFilter', () => {
expect(preventDefaultSpy).toHaveBeenCalled();
expect(keydownEvent.returnValue).toBeFalsy();
});

it('should use input (mocking android)', () => {
fixture.detectChanges();

keyfilter.isAndroid = true;
keyfilter.el.nativeElement.value = "PrimeNG";
fixture.detectChanges();

const inputEl = fixture.debugElement.query(By.css('input')).nativeElement;
const inputEvent: any = document.createEvent('CustomEvent');

inputEvent.initEvent('input', true, true);
inputEl.dispatchEvent(inputEvent);
fixture.detectChanges();

expect(keyfilter.el.nativeElement.value).not.toContain("PrimeNG");
keyfilter.el.nativeElement.value = "3507";
inputEl.dispatchEvent(inputEvent);
fixture.detectChanges();

keyfilter.el.nativeElement.value = "35a07";
inputEl.dispatchEvent(inputEvent);
fixture.detectChanges();

expect(keyfilter.el.nativeElement.value).toContain("3507");
});
});

0 comments on commit 2ddae69

Please sign in to comment.