Skip to content

Commit 9bab27d

Browse files
test adjustments
1 parent a21f3c6 commit 9bab27d

File tree

1 file changed

+1
-106
lines changed

1 file changed

+1
-106
lines changed

src/app/shared/form/builder/ds-dynamic-form-ui/models/date-picker/date-picker.component.spec.ts

Lines changed: 1 addition & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ import {
88
} from '@angular/core';
99
import {
1010
ComponentFixture,
11-
fakeAsync,
1211
inject,
1312
TestBed,
14-
tick,
15-
waitForAsync,
13+
waitForAsync
1614
} from '@angular/core/testing';
1715
import {
1816
UntypedFormControl,
1917
UntypedFormGroup,
2018
} from '@angular/forms';
21-
import { By } from '@angular/platform-browser';
2219
import {
2320
mockDynamicFormLayoutService,
2421
mockDynamicFormValidationService,
@@ -107,7 +104,6 @@ describe('DsDatePickerComponent test suite', () => {
107104
[group]='group'
108105
[model]='model'
109106
[legend]='legend'
110-
(blur)='onBlur($event)'
111107
(change)='onValueChange($event)'
112108
(focus)='onFocus($event)'></ds-date-picker>`;
113109

@@ -193,12 +189,6 @@ describe('DsDatePickerComponent test suite', () => {
193189
expect(dateComp.disabledDay).toBeFalsy();
194190
});
195191

196-
it('should emit blur Event onBlur', () => {
197-
spyOn(dateComp.blur, 'emit');
198-
dateComp.onBlur(new Event('blur'));
199-
expect(dateComp.blur.emit).toHaveBeenCalled();
200-
});
201-
202192
it('should emit focus Event onFocus', () => {
203193
spyOn(dateComp.focus, 'emit');
204194
dateComp.onFocus(new Event('focus'));
@@ -271,101 +261,6 @@ describe('DsDatePickerComponent test suite', () => {
271261
expect(dateComp.disabledDay).toBeFalsy();
272262
});
273263

274-
it('should move focus on month field when on year field and tab pressed', fakeAsync(() => {
275-
const event = {
276-
field: 'day',
277-
value: null,
278-
};
279-
const event1 = {
280-
field: 'month',
281-
value: null,
282-
};
283-
dateComp.onChange(event);
284-
dateComp.onChange(event1);
285-
286-
const yearElement = dateFixture.debugElement.query(By.css(`#${dateComp.model.id}_year`));
287-
const monthElement = dateFixture.debugElement.query(By.css(`#${dateComp.model.id}_month`));
288-
289-
yearElement.nativeElement.focus();
290-
dateFixture.detectChanges();
291-
292-
expect(document.activeElement).toBe(yearElement.nativeElement);
293-
294-
dateFixture.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'tab' }));
295-
dateFixture.detectChanges();
296-
297-
tick(200);
298-
dateFixture.detectChanges();
299-
300-
expect(document.activeElement).toBe(monthElement.nativeElement);
301-
}));
302-
303-
it('should move focus on day field when on month field and tab pressed', fakeAsync(() => {
304-
const event = {
305-
field: 'day',
306-
value: null,
307-
};
308-
dateComp.onChange(event);
309-
310-
const monthElement = dateFixture.debugElement.query(By.css(`#${dateComp.model.id}_month`));
311-
const dayElement = dateFixture.debugElement.query(By.css(`#${dateComp.model.id}_day`));
312-
313-
monthElement.nativeElement.focus();
314-
dateFixture.detectChanges();
315-
316-
expect(document.activeElement).toBe(monthElement.nativeElement);
317-
318-
dateFixture.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'tab' }));
319-
dateFixture.detectChanges();
320-
321-
tick(200);
322-
dateFixture.detectChanges();
323-
324-
expect(document.activeElement).toBe(dayElement.nativeElement);
325-
}));
326-
327-
it('should move focus on month field when on day field and shift tab pressed', fakeAsync(() => {
328-
const event = {
329-
field: 'day',
330-
value: null,
331-
};
332-
dateComp.onChange(event);
333-
334-
const monthElement = dateFixture.debugElement.query(By.css(`#${dateComp.model.id}_month`));
335-
const dayElement = dateFixture.debugElement.query(By.css(`#${dateComp.model.id}_day`));
336-
337-
dayElement.nativeElement.focus();
338-
dateFixture.detectChanges();
339-
340-
expect(document.activeElement).toBe(dayElement.nativeElement);
341-
342-
dateFixture.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'shift.tab' }));
343-
dateFixture.detectChanges();
344-
345-
tick(200);
346-
dateFixture.detectChanges();
347-
348-
expect(document.activeElement).toBe(monthElement.nativeElement);
349-
}));
350-
351-
it('should move focus on year field when on month field and shift tab pressed', fakeAsync(() => {
352-
const yearElement = dateFixture.debugElement.query(By.css(`#${dateComp.model.id}_year`));
353-
const monthElement = dateFixture.debugElement.query(By.css(`#${dateComp.model.id}_month`));
354-
355-
monthElement.nativeElement.focus();
356-
dateFixture.detectChanges();
357-
358-
expect(document.activeElement).toBe(monthElement.nativeElement);
359-
360-
dateFixture.nativeElement.dispatchEvent(new KeyboardEvent('keydown', { key: 'shift.tab' }));
361-
dateFixture.detectChanges();
362-
363-
tick(200);
364-
dateFixture.detectChanges();
365-
366-
expect(document.activeElement).toBe(yearElement.nativeElement);
367-
}));
368-
369264
});
370265
});
371266

0 commit comments

Comments
 (0)