44 TestBed
55} from '@angular/core/testing' ;
66import { By } from '@angular/platform-browser' ;
7- import { IgxTextSelectionModule } from './text-selection.directive' ;
7+ import { IgxTextSelectionModule } from './text-selection.directive' ;
88
99import { configureTestSuite } from '../../test-utils/configure-suite' ;
1010
@@ -14,13 +14,14 @@ describe('IgxSelection', () => {
1414 TestBed . configureTestingModule ( {
1515 declarations : [
1616 TriggerTextSelectionComponent ,
17- TriggerTextSelectionOnClickComponent
17+ TriggerTextSelectionOnClickComponent ,
18+ TriggerTextSelectionFalseOnClickComponent
1819 ] ,
1920 imports : [ IgxTextSelectionModule ]
2021 } ) ;
2122 } ) ) ;
2223
23- it ( 'Should select the text which is into the input' , async ( ) => {
24+ it ( 'Should select the text which is into the input' , async ( ) => {
2425 const fix = TestBed . createComponent ( TriggerTextSelectionComponent ) ;
2526 fix . detectChanges ( ) ;
2627
@@ -34,7 +35,7 @@ describe('IgxSelection', () => {
3435 } ) ;
3536 } ) ;
3637
37- it ( 'Should select the text when the input is clicked' , async ( ) => {
38+ it ( 'Should select the text when the input is clicked' , async ( ) => {
3839 const fix = TestBed . createComponent ( TriggerTextSelectionOnClickComponent ) ;
3940 fix . detectChanges ( ) ;
4041
@@ -52,26 +53,19 @@ describe('IgxSelection', () => {
5253 } ) ;
5354 } ) ;
5455
55- it ( 'Shouldn\'t make a selection when the state is set to false' , ( ) => {
56- const template = ` <input type="text" [igxTextSelection]="false" #select="igxTextSelection"
57- (click)="select.trigger()" value="Some custom value!" />` ;
58-
59- TestBed . overrideTemplateUsingTestingModule ( TriggerTextSelectionOnClickComponent , template ) ;
60-
61- TestBed . compileComponents ( ) . then ( ( ) => {
62- const fix = TestBed . createComponent ( TriggerTextSelectionOnClickComponent ) ;
63- fix . detectChanges ( ) ;
56+ it ( 'Shouldn\'t make a selection when the state is set to false' , async ( ) => {
57+ const fix = TestBed . createComponent ( TriggerTextSelectionFalseOnClickComponent ) ;
58+ fix . detectChanges ( ) ;
6459
65- const input = fix . debugElement . query ( By . css ( 'input' ) ) ;
66- const inputNativeElem = input . nativeElement ;
67- const inputElem : HTMLElement = input . nativeElement ;
60+ const input = fix . debugElement . query ( By . css ( 'input' ) ) ;
61+ const inputNativeElem = input . nativeElement ;
62+ const inputElem : HTMLElement = input . nativeElement ;
6863
69- inputElem . click ( ) ;
70- fix . detectChanges ( ) ;
64+ inputElem . click ( ) ;
65+ fix . detectChanges ( ) ;
7166
72- expect ( inputNativeElem . selectionEnd ) . toEqual ( 0 ) ;
73- expect ( inputNativeElem . value . substring ( inputNativeElem . selectionStart , inputNativeElem . selectionEnd ) ) . toEqual ( '' ) ;
74- } ) ;
67+ expect ( inputNativeElem . selectionEnd ) . toEqual ( 0 ) ;
68+ expect ( inputNativeElem . value . substring ( inputNativeElem . selectionStart , inputNativeElem . selectionEnd ) ) . toEqual ( '' ) ;
7569 } ) ;
7670} ) ;
7771
@@ -81,12 +75,19 @@ describe('IgxSelection', () => {
8175 <input type="text" [igxTextSelection]="true" value="Some custom value!" />
8276 `
8377} )
84- class TriggerTextSelectionComponent { }
78+ class TriggerTextSelectionComponent { }
8579
8680@Component ( {
8781 template :
8882 `
8983 <input type="text" [igxTextSelection] #select="igxTextSelection" (click)="select.trigger()" value="Some custom value!" />
9084 `
9185} )
92- class TriggerTextSelectionOnClickComponent { }
86+ class TriggerTextSelectionOnClickComponent { }
87+ @Component ( {
88+ template :
89+ `
90+ <input type="text" [igxTextSelection]="false" #select="igxTextSelection" (click)="select.trigger()" value="Some custom value!" />
91+ `
92+ } )
93+ class TriggerTextSelectionFalseOnClickComponent { }
0 commit comments