Skip to content

Commit 9c8a343

Browse files
committed
fix(TextSelDir): made test fakeasync and test tel
1 parent 4900544 commit 9c8a343

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

projects/igniteui-angular/src/lib/directives/text-selection/text-selection.directive.spec.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, DebugElement, ViewChild } from '@angular/core';
2-
import { TestBed, waitForAsync } from '@angular/core/testing';
2+
import { fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import { IgxTextSelectionModule } from './text-selection.directive';
55

@@ -45,7 +45,7 @@ describe('IgxSelection', () => {
4545
.toEqual(inputNativeElem.value);
4646
});
4747

48-
it('Should check if the value is selected if based on input type', () => {
48+
it('Should check if the value is selected if based on input type', fakeAsync(() => {
4949
const fix = TestBed.createComponent(TriggerTextSelectionOnClickComponent);
5050
const selectableTypes: Types[] = [
5151
{ "text" : "Some Values!" },
@@ -82,19 +82,16 @@ describe('IgxSelection', () => {
8282
inputElem.click();
8383
fix.detectChanges();
8484

85-
if(type !== 'number' && type !== 'tel'){
85+
if(type !== 'number'){
8686
expect(inputNativeElem.selectionEnd).toEqual(inputNativeElem.value.length);
8787
expect(inputNativeElem.value.substring(inputNativeElem.selectionStart, inputNativeElem.selectionEnd))
8888
.toEqual(val);
8989
}
9090

9191
if(type === 'number'){
9292
let selection = document.getSelection().toString();
93-
console.log(selection);
94-
console.log(val)
95-
fix.componentInstance.waitForOneSecond().then(() => {
96-
expect(val.toString().lenght).toBe(selection.length);
97-
});
93+
tick(1000);
94+
expect((String(val)).length).toBe(selection.length);
9895
}
9996
});
10097

@@ -109,7 +106,7 @@ describe('IgxSelection', () => {
109106
fix.detectChanges();
110107
expect(inputNativeElem.selectionStart).toEqual(inputNativeElem.selectionEnd);
111108
});
112-
});
109+
}));
113110

114111

115112

0 commit comments

Comments
 (0)