@@ -11,8 +11,8 @@ import {
11
11
import { FormsModule , FormControl , ReactiveFormsModule } from '@angular/forms' ;
12
12
import { Component , ViewChild , ViewChildren , QueryList , ElementRef , Sanitizer , SecurityContext } from '@angular/core' ;
13
13
import { ThySelectModule } from './module' ;
14
- import { ThySelectCustomComponent , SelectMode } from './custom-select.component' ;
15
- import { ThyOptionComponent } from './option.component' ;
14
+ import { ThySelectCustomComponent , SelectMode } from './custom-select/custom-select .component' ;
15
+ import { ThyOptionComponent } from './custom-select/ option.component' ;
16
16
import { By , DomSanitizer } from '@angular/platform-browser' ;
17
17
import { UpdateHostClassService } from '../shared' ;
18
18
import { ThyPositioningService } from '../positioning/positioning.service' ;
@@ -656,7 +656,9 @@ describe('ThyCustomSelect', () => {
656
656
657
657
expect ( option . classList ) . toContain ( 'active' ) ;
658
658
expect ( fixture . componentInstance . options . first . selected ) . toEqual ( true ) ;
659
- expect ( fixture . componentInstance . select . selected ) . toBe ( fixture . componentInstance . options . first ) ;
659
+ expect ( fixture . componentInstance . select . _selectionModel . selected [ 0 ] ) . toBe (
660
+ fixture . componentInstance . options . first
661
+ ) ;
660
662
} ) ) ;
661
663
662
664
it ( 'should be able to select to an option using th ThyOptionComponent API' , fakeAsync ( ( ) => {
@@ -672,7 +674,7 @@ describe('ThyCustomSelect', () => {
672
674
flush ( ) ;
673
675
expect ( optionNodes [ 1 ] . classList ) . toContain ( 'active' ) ;
674
676
expect ( optionInstances [ 1 ] . selected ) . toBe ( true ) ;
675
- expect ( fixture . componentInstance . select . selected ) . toBe ( optionInstances [ 1 ] ) ;
677
+ expect ( fixture . componentInstance . select . _selectionModel . selected [ 0 ] ) . toBe ( optionInstances [ 1 ] ) ;
676
678
} ) ) ;
677
679
678
680
it ( 'should deselect other options when one is selected' , fakeAsync ( ( ) => {
@@ -853,7 +855,7 @@ describe('ThyCustomSelect', () => {
853
855
fixture . detectChanges ( ) ;
854
856
855
857
expect ( fixture . componentInstance . select . thyShowSearch ) . toBe ( true ) ;
856
- expect ( overlayContainerElement . querySelector ( 'thy -input-search' ) ) . not . toBeNull ( ) ;
858
+ expect ( fixture . debugElement . query ( By . css ( '.search -input-field' ) ) ) . not . toBeNull ( ) ;
857
859
} ) ) ;
858
860
it ( 'should hide the options that can not be searched' , fakeAsync ( ( ) => {
859
861
const fixture = TestBed . createComponent ( SelectWithSearchComponent ) ;
@@ -863,9 +865,10 @@ describe('ThyCustomSelect', () => {
863
865
trigger . click ( ) ;
864
866
fixture . detectChanges ( ) ;
865
867
866
- const input = overlayContainerElement . querySelector ( ' input' ) ;
868
+ const input = fixture . debugElement . query ( By . css ( '.search- input-field' ) ) . nativeElement ;
867
869
868
870
typeInElement ( 'Steak' , input ) ;
871
+ flush ( ) ;
869
872
fixture . detectChanges ( ) ;
870
873
flush ( ) ;
871
874
@@ -888,12 +891,12 @@ describe('ThyCustomSelect', () => {
888
891
} ) ) ;
889
892
it ( 'should search option use thySearchKey' , fakeAsync ( ( ) => {
890
893
const fixture = TestBed . createComponent ( SelectWithSearchUseSearchKeyComponent ) ;
891
- const trigger = fixture . debugElement . query ( By . css ( '.form-control-custom' ) ) . nativeElement ;
892
894
fixture . detectChanges ( ) ;
895
+ const trigger = fixture . debugElement . query ( By . css ( '.form-control-custom' ) ) . nativeElement ;
893
896
trigger . click ( ) ;
894
897
fixture . detectChanges ( ) ;
895
898
896
- const input = overlayContainerElement . querySelector ( ' input' ) ;
899
+ const input = fixture . debugElement . query ( By . css ( '.search- input-field' ) ) . nativeElement ;
897
900
898
901
typeInElement ( 'lrs' , input ) ;
899
902
fixture . detectChanges ( ) ;
@@ -914,15 +917,14 @@ describe('ThyCustomSelect', () => {
914
917
} ) ) ;
915
918
it ( 'should hide the thy-group when all options of the group is hidden' , fakeAsync ( ( ) => {
916
919
const fixture = TestBed . createComponent ( SelectWithSearchAndGroupComponent ) ;
917
- const trigger = fixture . debugElement . query ( By . css ( '.form-control-custom' ) ) . nativeElement ;
918
-
919
920
fixture . detectChanges ( ) ;
921
+ const trigger = fixture . debugElement . query ( By . css ( '.form-control-custom' ) ) . nativeElement ;
920
922
trigger . click ( ) ;
921
923
fixture . detectChanges ( ) ;
922
924
923
925
const groups = fixture . componentInstance . select . optionGroups . toArray ( ) ;
924
926
const options = fixture . componentInstance . select . options . toArray ( ) ;
925
- const input = overlayContainerElement . querySelector ( ' input' ) ;
927
+ const input = fixture . debugElement . query ( By . css ( '.search- input-field' ) ) . nativeElement ;
926
928
typeInElement ( 'Cat' , input ) ;
927
929
928
930
tick ( 1000 ) ;
@@ -943,13 +945,14 @@ describe('ThyCustomSelect', () => {
943
945
} ) ) ;
944
946
it ( 'should exec thyOnSearch when thyServerSearch is true' , fakeAsync ( ( ) => {
945
947
const fixture = TestBed . createComponent ( SelectWithSearchAndServerSearchComponent ) ;
946
- const trigger = fixture . debugElement . query ( By . css ( '.form-control-custom' ) ) . nativeElement ;
947
948
fixture . detectChanges ( ) ;
949
+ const trigger = fixture . debugElement . query ( By . css ( '.form-control-custom' ) ) . nativeElement ;
948
950
trigger . click ( ) ;
949
951
fixture . detectChanges ( ) ;
950
952
951
953
const spy = fixture . componentInstance . thyOnSearch ;
952
- const input = overlayContainerElement . querySelector ( 'input' ) ;
954
+ const input = fixture . debugElement . query ( By . css ( '.search-input-field' ) ) . nativeElement ;
955
+
953
956
typeInElement ( 'milk' , input ) ;
954
957
fixture . detectChanges ( ) ;
955
958
tick ( ) ;
@@ -965,8 +968,8 @@ describe('ThyCustomSelect', () => {
965
968
966
969
it ( 'should remove the thy-option when sourcedata change' , fakeAsync ( ( ) => {
967
970
const fixture = TestBed . createComponent ( SelectEimtOptionsChangesComponent ) ;
968
- const trigger = fixture . debugElement . query ( By . css ( '.form-control-custom' ) ) . nativeElement ;
969
971
fixture . detectChanges ( ) ;
972
+ const trigger = fixture . debugElement . query ( By . css ( '.form-control-custom' ) ) . nativeElement ;
970
973
trigger . click ( ) ;
971
974
fixture . detectChanges ( ) ;
972
975
@@ -1002,7 +1005,7 @@ describe('ThyCustomSelect', () => {
1002
1005
fixture . detectChanges ( ) ;
1003
1006
flush ( ) ;
1004
1007
1005
- const selectContainer = overlayContainerElement . querySelector ( '.thy-select-container ' ) ;
1008
+ const selectContainer = overlayContainerElement . querySelector ( '.thy-custom- select-dropdown ' ) ;
1006
1009
dispatchFakeEvent ( selectContainer , 'mouseleave' ) ;
1007
1010
fixture . detectChanges ( ) ;
1008
1011
0 commit comments