@@ -10,7 +10,7 @@ import __search = services.search;
10
10
11
11
import { ComponentValidator } from '../../../services/componentValidator/componentValidator.service' ;
12
12
13
- import { TypeaheadComponent , DEFAULT_SERVER_SEARCH_DEBOUNCE } from './typeahead' ;
13
+ import { TypeaheadComponent , DEFAULT_SERVER_SEARCH_DEBOUNCE , DEFAULT_CLIENT_SEARCH_DEBOUNCE } from './typeahead' ;
14
14
15
15
interface ITransformMock {
16
16
getValue : Sinon . SinonSpy ;
@@ -69,6 +69,38 @@ describe('TypeaheadComponent', () => {
69
69
expect ( typeahead . collapsed ) . to . be . true ;
70
70
} ) ;
71
71
72
+ describe ( 'debounce' , ( ) => {
73
+ it ( 'should use the default server search debounce by default' , ( ) => {
74
+ typeahead . ngOnInit ( ) ;
75
+ expect ( typeahead . loadDelay ) . to . equal ( DEFAULT_SERVER_SEARCH_DEBOUNCE ) ;
76
+ } ) ;
77
+
78
+ it ( 'should use the default client search debounce if client searching is on' , ( ) => {
79
+ typeahead . clientSearch = true ;
80
+ typeahead . ngOnInit ( ) ;
81
+ expect ( typeahead . loadDelay ) . to . equal ( DEFAULT_CLIENT_SEARCH_DEBOUNCE ) ;
82
+ } ) ;
83
+
84
+ it ( 'should use the custom debounce when client searching is off' , ( ) => {
85
+ const debounce = 10000 ;
86
+ typeahead . debounce = debounce ;
87
+
88
+ typeahead . ngOnInit ( ) ;
89
+
90
+ expect ( typeahead . loadDelay ) . to . equal ( debounce ) ;
91
+ } ) ;
92
+
93
+ it ( 'should use the custom debounce when client searching is on' , ( ) => {
94
+ const debounce = 10000 ;
95
+ typeahead . debounce = debounce ;
96
+
97
+ typeahead . clientSearch = true ;
98
+ typeahead . ngOnInit ( ) ;
99
+
100
+ expect ( typeahead . loadDelay ) . to . equal ( debounce ) ;
101
+ } ) ;
102
+ } ) ;
103
+
72
104
describe ( 'loadItems' , ( ) : void => {
73
105
let items : string [ ] ;
74
106
0 commit comments