1
- import { Component , DebugElement , ElementRef , ViewChild } from '@angular/core' ;
1
+ import {
2
+ Component ,
3
+ ɵZONELESS_ENABLED ,
4
+ DebugElement ,
5
+ ElementRef ,
6
+ ViewChild ,
7
+ signal ,
8
+ } from '@angular/core' ;
2
9
import { ComponentFixture , TestBed , waitForAsync } from '@angular/core/testing' ;
3
10
import { By } from '@angular/platform-browser' ;
4
11
import { CdkComboboxModule } from './combobox-module' ;
@@ -25,6 +32,7 @@ describe('Combobox', () => {
25
32
26
33
beforeEach ( waitForAsync ( ( ) => {
27
34
TestBed . configureTestingModule ( {
35
+ providers : [ { provide : ɵZONELESS_ENABLED , useValue : false } ] ,
28
36
imports : [ CdkComboboxModule , ComboboxToggle ] ,
29
37
} ) . compileComponents ( ) ;
30
38
} ) ) ;
@@ -83,7 +91,7 @@ describe('Combobox', () => {
83
91
84
92
it ( 'should toggle focus upon toggling the panel' , ( ) => {
85
93
comboboxElement . focus ( ) ;
86
- testComponent . actions = 'toggle' ;
94
+ testComponent . actions . set ( 'toggle' ) ;
87
95
fixture . detectChanges ( ) ;
88
96
89
97
expect ( document . activeElement ) . toEqual ( comboboxElement ) ;
@@ -209,7 +217,7 @@ describe('Combobox', () => {
209
217
} ) ;
210
218
211
219
it ( 'should coerce actions separated by space' , ( ) => {
212
- testComponent . actions = 'focus click' ;
220
+ testComponent . actions . set ( 'focus click' ) ;
213
221
fixture . detectChanges ( ) ;
214
222
215
223
const openActions = comboboxInstance . openActions ;
@@ -219,7 +227,7 @@ describe('Combobox', () => {
219
227
} ) ;
220
228
221
229
it ( 'should coerce actions separated by comma' , ( ) => {
222
- testComponent . actions = 'focus,click,downKey' ;
230
+ testComponent . actions . set ( 'focus,click,downKey' ) ;
223
231
fixture . detectChanges ( ) ;
224
232
225
233
const openActions = comboboxInstance . openActions ;
@@ -230,7 +238,7 @@ describe('Combobox', () => {
230
238
} ) ;
231
239
232
240
it ( 'should coerce actions separated by commas and spaces' , ( ) => {
233
- testComponent . actions = 'focus click,downKey' ;
241
+ testComponent . actions . set ( 'focus click,downKey' ) ;
234
242
fixture . detectChanges ( ) ;
235
243
236
244
const openActions = comboboxInstance . openActions ;
@@ -241,10 +249,10 @@ describe('Combobox', () => {
241
249
} ) ;
242
250
243
251
it ( 'should throw error when given invalid open action' , ( ) => {
244
- expect ( ( ) => {
245
- testComponent . actions = 'invalidAction' ;
246
- fixture . detectChanges ( ) ;
247
- } ) . toThrow ( ) ;
252
+ const errorSpy = spyOn ( console , 'error' ) ;
253
+ testComponent . actions . set ( 'invalidAction' ) ;
254
+ fixture . detectChanges ( ) ;
255
+ expect ( errorSpy ) . toHaveBeenCalled ( ) ;
248
256
} ) ;
249
257
} ) ;
250
258
@@ -274,7 +282,7 @@ describe('Combobox', () => {
274
282
} ) ;
275
283
276
284
it ( 'should open panel with focus open action' , ( ) => {
277
- testComponent . actions = 'focus' ;
285
+ testComponent . actions . set ( 'focus' ) ;
278
286
fixture . detectChanges ( ) ;
279
287
280
288
expect ( comboboxInstance . isOpen ( ) ) . toBeFalse ( ) ;
@@ -286,7 +294,7 @@ describe('Combobox', () => {
286
294
} ) ;
287
295
288
296
it ( 'should open panel with click open action' , ( ) => {
289
- testComponent . actions = 'click' ;
297
+ testComponent . actions . set ( 'click' ) ;
290
298
fixture . detectChanges ( ) ;
291
299
292
300
expect ( comboboxInstance . isOpen ( ) ) . toBeFalse ( ) ;
@@ -298,7 +306,7 @@ describe('Combobox', () => {
298
306
} ) ;
299
307
300
308
it ( 'should open panel with downKey open action' , ( ) => {
301
- testComponent . actions = 'downKey' ;
309
+ testComponent . actions . set ( 'downKey' ) ;
302
310
fixture . detectChanges ( ) ;
303
311
304
312
expect ( comboboxInstance . isOpen ( ) ) . toBeFalse ( ) ;
@@ -310,7 +318,7 @@ describe('Combobox', () => {
310
318
} ) ;
311
319
312
320
it ( 'should toggle panel with toggle open action' , ( ) => {
313
- testComponent . actions = 'toggle' ;
321
+ testComponent . actions . set ( 'toggle' ) ;
314
322
fixture . detectChanges ( ) ;
315
323
316
324
expect ( comboboxInstance . isOpen ( ) ) . toBeFalse ( ) ;
@@ -327,7 +335,7 @@ describe('Combobox', () => {
327
335
} ) ;
328
336
329
337
it ( 'should close panel on escape key' , ( ) => {
330
- testComponent . actions = 'click' ;
338
+ testComponent . actions . set ( 'click' ) ;
331
339
fixture . detectChanges ( ) ;
332
340
333
341
expect ( comboboxInstance . isOpen ( ) ) . toBeFalse ( ) ;
@@ -344,7 +352,7 @@ describe('Combobox', () => {
344
352
} ) ;
345
353
346
354
it ( 'should handle multiple open actions' , ( ) => {
347
- testComponent . actions = 'click downKey' ;
355
+ testComponent . actions . set ( 'click downKey' ) ;
348
356
fixture . detectChanges ( ) ;
349
357
350
358
expect ( comboboxInstance . isOpen ( ) ) . toBeFalse ( ) ;
@@ -371,7 +379,7 @@ describe('Combobox', () => {
371
379
template : `
372
380
<button cdkCombobox #toggleCombobox="cdkCombobox" class="example-combobox"
373
381
[cdkComboboxTriggerFor]="panel"
374
- [openActions]="actions">
382
+ [openActions]="actions() ">
375
383
No Value
376
384
</button>
377
385
<div id="other-content"></div>
@@ -388,5 +396,5 @@ describe('Combobox', () => {
388
396
class ComboboxToggle {
389
397
@ViewChild ( 'input' ) inputElement : ElementRef < HTMLInputElement > ;
390
398
391
- actions : string = 'click' ;
399
+ actions = signal ( 'click' ) ;
392
400
}
0 commit comments