1
1
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' ;
3
3
import { By } from '@angular/platform-browser' ;
4
4
import { IgxTextSelectionModule } from './text-selection.directive' ;
5
5
@@ -45,7 +45,7 @@ describe('IgxSelection', () => {
45
45
. toEqual ( inputNativeElem . value ) ;
46
46
} ) ;
47
47
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 ( ( ) => {
49
49
const fix = TestBed . createComponent ( TriggerTextSelectionOnClickComponent ) ;
50
50
const selectableTypes : Types [ ] = [
51
51
{ "text" : "Some Values!" } ,
@@ -82,19 +82,16 @@ describe('IgxSelection', () => {
82
82
inputElem . click ( ) ;
83
83
fix . detectChanges ( ) ;
84
84
85
- if ( type !== 'number' && type !== 'tel' ) {
85
+ if ( type !== 'number' ) {
86
86
expect ( inputNativeElem . selectionEnd ) . toEqual ( inputNativeElem . value . length ) ;
87
87
expect ( inputNativeElem . value . substring ( inputNativeElem . selectionStart , inputNativeElem . selectionEnd ) )
88
88
. toEqual ( val ) ;
89
89
}
90
90
91
91
if ( type === 'number' ) {
92
92
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 ) ;
98
95
}
99
96
} ) ;
100
97
@@ -109,7 +106,7 @@ describe('IgxSelection', () => {
109
106
fix . detectChanges ( ) ;
110
107
expect ( inputNativeElem . selectionStart ) . toEqual ( inputNativeElem . selectionEnd ) ;
111
108
} ) ;
112
- } ) ;
109
+ } ) ) ;
113
110
114
111
115
112
0 commit comments