@imihai/angular-datetime-picker 21.0.2 → 22.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.browserslistrc +9 -0
- package/.editorconfig +13 -0
- package/.eslintrc.js +208 -0
- package/.github/workflows/ci_test.yml +35 -0
- package/.prettierrc +2 -0
- package/.travis.yml +16 -0
- package/angular.json +221 -0
- package/e2e/protractor.conf.js +28 -0
- package/e2e/src/app.e2e-spec.ts +14 -0
- package/e2e/src/app.po.ts +11 -0
- package/e2e/tsconfig.e2e.json +13 -0
- package/package.json +77 -33
- package/projects/picker/karma.conf.js +62 -0
- package/projects/picker/ng-package.json +7 -0
- package/projects/picker/package.json +23 -0
- package/projects/picker/src/lib/date-time/adapter/date-time-adapter.class.ts +313 -0
- package/projects/picker/src/lib/date-time/adapter/date-time-format.class.ts +18 -0
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-adapter.class.ts +307 -0
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time-format.class.ts +11 -0
- package/projects/picker/src/lib/date-time/adapter/luxon-date-time.module.ts +31 -0
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-adapter.class.ts +356 -0
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time-format.class.ts +14 -0
- package/projects/picker/src/lib/date-time/adapter/unix-timestamp-adapter/unix-timestamp-date-time.module.ts +26 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.html +38 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.spec.ts +120 -0
- package/projects/picker/src/lib/date-time/calendar-body.component.ts +190 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.html +47 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.scss +16 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.spec.ts +394 -0
- package/projects/picker/src/lib/date-time/calendar-month-view.component.ts +705 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.html +44 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.spec.ts +343 -0
- package/projects/picker/src/lib/date-time/calendar-multi-year-view.component.ts +465 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.html +16 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.spec.ts +381 -0
- package/projects/picker/src/lib/date-time/calendar-year-view.component.ts +549 -0
- package/projects/picker/src/lib/date-time/calendar.component.html +169 -0
- package/projects/picker/src/lib/date-time/calendar.component.scss +0 -0
- package/projects/picker/src/lib/date-time/calendar.component.spec.ts +592 -0
- package/projects/picker/src/lib/date-time/calendar.component.ts +496 -0
- package/projects/picker/src/lib/date-time/date-time-inline.component.html +1 -0
- package/projects/picker/src/lib/date-time/date-time-inline.component.scss +4 -0
- package/projects/picker/src/lib/date-time/date-time-inline.component.ts +365 -0
- package/projects/picker/src/lib/date-time/date-time-picker-animation-event.ts +4 -0
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.html +126 -0
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.scss +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker-container.component.ts +631 -0
- package/projects/picker/src/lib/date-time/date-time-picker-input.directive.ts +851 -0
- package/projects/picker/src/lib/date-time/date-time-picker-intl.service.ts +76 -0
- package/projects/picker/src/lib/date-time/date-time-picker-trigger.directive.ts +88 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.html +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.scss +0 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.spec.ts +2648 -0
- package/projects/picker/src/lib/date-time/date-time-picker.component.ts +731 -0
- package/projects/picker/src/lib/date-time/date-time.class.ts +256 -0
- package/projects/picker/src/lib/date-time/date-time.module.ts +61 -0
- package/projects/picker/src/lib/date-time/numberedFixLen.pipe.ts +28 -0
- package/projects/picker/src/lib/date-time/options-provider.ts +44 -0
- package/projects/picker/src/lib/date-time/timer-box.component.html +79 -0
- package/projects/picker/src/lib/date-time/timer-box.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer-box.component.ts +175 -0
- package/projects/picker/src/lib/date-time/timer.component.html +58 -0
- package/projects/picker/src/lib/date-time/timer.component.scss +0 -0
- package/projects/picker/src/lib/date-time/timer.component.spec.ts +399 -0
- package/projects/picker/src/lib/date-time/timer.component.ts +371 -0
- package/projects/picker/src/lib/dialog/dialog-config.class.ts +220 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.html +1 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.scss +0 -0
- package/projects/picker/src/lib/dialog/dialog-container.component.ts +231 -0
- package/projects/picker/src/lib/dialog/dialog-ref.class.ts +178 -0
- package/projects/picker/src/lib/dialog/dialog.module.ts +25 -0
- package/projects/picker/src/lib/dialog/dialog.service.ts +353 -0
- package/projects/picker/src/lib/utils/array.utils.ts +12 -0
- package/projects/picker/src/lib/utils/constants.ts +59 -0
- package/projects/picker/src/lib/utils/date.utils.ts +97 -0
- package/projects/picker/src/lib/utils/index.ts +5 -0
- package/projects/picker/src/lib/utils/object.utils.ts +29 -0
- package/projects/picker/src/public_api.ts +56 -0
- package/projects/picker/src/sass/picker.scss +743 -0
- package/projects/picker/src/test-helpers.ts +125 -0
- package/projects/picker/src/test.ts +52 -0
- package/projects/picker/tsconfig.lib.json +19 -0
- package/projects/picker/tsconfig.lib.prod.json +7 -0
- package/projects/picker/tsconfig.spec.json +17 -0
- package/projects/picker/tslint.json +8 -0
- package/src/app/app.component.html +77 -0
- package/src/app/app.component.scss +32 -0
- package/src/app/app.component.spec.ts +16 -0
- package/src/app/app.component.ts +35 -0
- package/src/assets/.gitkeep +0 -0
- package/src/environments/environment.prod.ts +3 -0
- package/src/environments/environment.ts +16 -0
- package/src/favicon.ico +0 -0
- package/src/index.html +14 -0
- package/src/karma.conf.js +31 -0
- package/src/main.ts +16 -0
- package/src/polyfills.ts +53 -0
- package/src/styles.scss +7 -0
- package/src/test.ts +50 -0
- package/src/tsconfig.app.json +16 -0
- package/src/tsconfig.spec.json +18 -0
- package/src/tslint.json +17 -0
- package/tsconfig.base.json +31 -0
- package/tsconfig.json +30 -0
- package/tslint.json +130 -0
- package/assets/style/picker.min.css +0 -1
- package/fesm2022/imihai-angular-datetime-picker.mjs +0 -5845
- package/fesm2022/imihai-angular-datetime-picker.mjs.map +0 -1
- package/imihai-angular-datetime-picker-21.0.2.tgz +0 -0
- package/types/imihai-angular-datetime-picker.d.ts +0 -2193
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* timer.component.spec
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { EventEmitter } from '@angular/core';
|
|
6
|
+
import {
|
|
7
|
+
ComponentFixture,
|
|
8
|
+
fakeAsync,
|
|
9
|
+
flush,
|
|
10
|
+
TestBed
|
|
11
|
+
} from '@angular/core/testing';
|
|
12
|
+
import { OwlDateTimeIntl } from './date-time-picker-intl.service';
|
|
13
|
+
import { Component, DebugElement, NgZone } from '@angular/core';
|
|
14
|
+
import { discardPeriodicTasks } from '@angular/core/testing';
|
|
15
|
+
import { OwlNativeDateTimeModule } from './adapter/native-date-time.module';
|
|
16
|
+
import { OwlDateTimeModule } from './date-time.module';
|
|
17
|
+
import { By } from '@angular/platform-browser';
|
|
18
|
+
import { OwlTimerComponent } from './timer.component';
|
|
19
|
+
import { dispatchFakeEvent } from '../../test-helpers';
|
|
20
|
+
|
|
21
|
+
const JAN = 0,
|
|
22
|
+
FEB = 1,
|
|
23
|
+
MAR = 2,
|
|
24
|
+
APR = 3,
|
|
25
|
+
MAY = 4,
|
|
26
|
+
JUN = 5,
|
|
27
|
+
JUL = 6,
|
|
28
|
+
AUG = 7,
|
|
29
|
+
SEP = 8,
|
|
30
|
+
OCT = 9,
|
|
31
|
+
NOV = 10,
|
|
32
|
+
DEC = 11;
|
|
33
|
+
|
|
34
|
+
class MockNgZone extends NgZone {
|
|
35
|
+
onStable: EventEmitter<any> = new EventEmitter(false);
|
|
36
|
+
constructor() {
|
|
37
|
+
super({ enableLongStackTrace: false });
|
|
38
|
+
}
|
|
39
|
+
run(fn: Function): any {
|
|
40
|
+
return fn();
|
|
41
|
+
}
|
|
42
|
+
runOutsideAngular(fn: Function): any {
|
|
43
|
+
return fn();
|
|
44
|
+
}
|
|
45
|
+
simulateZoneExit(): void {
|
|
46
|
+
this.onStable.emit(null);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
describe('OwlTimerComponent', () => {
|
|
51
|
+
let zone: MockNgZone;
|
|
52
|
+
|
|
53
|
+
beforeEach(() => {
|
|
54
|
+
TestBed.configureTestingModule({
|
|
55
|
+
imports: [OwlNativeDateTimeModule, OwlDateTimeModule],
|
|
56
|
+
declarations: [StandardTimerComponent],
|
|
57
|
+
providers: [
|
|
58
|
+
OwlDateTimeIntl,
|
|
59
|
+
{ provide: NgZone, useFactory: () => (zone = new MockNgZone()) }
|
|
60
|
+
]
|
|
61
|
+
}).compileComponents();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('standard timer', () => {
|
|
65
|
+
let fixture: ComponentFixture<StandardTimerComponent>;
|
|
66
|
+
let testComponent: StandardTimerComponent;
|
|
67
|
+
let timerDebugElement: DebugElement;
|
|
68
|
+
let timerElement: HTMLElement;
|
|
69
|
+
let timerInstance: OwlTimerComponent<Date>;
|
|
70
|
+
|
|
71
|
+
beforeEach(() => {
|
|
72
|
+
fixture = TestBed.createComponent(StandardTimerComponent);
|
|
73
|
+
fixture.detectChanges();
|
|
74
|
+
|
|
75
|
+
timerDebugElement = fixture.debugElement.query(
|
|
76
|
+
By.directive(OwlTimerComponent)
|
|
77
|
+
);
|
|
78
|
+
timerElement = timerDebugElement.nativeElement;
|
|
79
|
+
testComponent = fixture.componentInstance;
|
|
80
|
+
timerInstance = timerDebugElement.componentInstance;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('should have two timer boxes if showSecondsTimer set to false', () => {
|
|
84
|
+
const timerBoxes = timerElement.querySelectorAll(
|
|
85
|
+
'owl-date-time-timer-box'
|
|
86
|
+
);
|
|
87
|
+
expect(timerInstance.showSecondsTimer).toBeFalsy();
|
|
88
|
+
expect(timerBoxes.length).toBe(2);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('should have three timer boxes if showSecondsTimer set to true', () => {
|
|
92
|
+
testComponent.showSecondsTimer = true;
|
|
93
|
+
fixture.detectChanges();
|
|
94
|
+
|
|
95
|
+
const timerBoxes = timerElement.querySelectorAll(
|
|
96
|
+
'owl-date-time-timer-box'
|
|
97
|
+
);
|
|
98
|
+
expect(timerInstance.showSecondsTimer).toBeTruthy();
|
|
99
|
+
expect(timerBoxes.length).toBe(3);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should NOT have the hour12 toggle button if hour12Timer set to false', () => {
|
|
103
|
+
const toggleBtn = timerElement.querySelector(
|
|
104
|
+
'button.owl-dt-timer-hour12-box'
|
|
105
|
+
);
|
|
106
|
+
expect(timerInstance.hour12Timer).toBeFalsy();
|
|
107
|
+
expect(toggleBtn).toBeFalsy();
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should have the hour12 toggle button if hour12Timer set to true', () => {
|
|
111
|
+
testComponent.hour12Timer = true;
|
|
112
|
+
fixture.detectChanges();
|
|
113
|
+
|
|
114
|
+
const toggleBtn = timerElement.querySelector(
|
|
115
|
+
'button.owl-dt-timer-hour12-box'
|
|
116
|
+
);
|
|
117
|
+
expect(timerInstance.hour12Timer).toBeTruthy();
|
|
118
|
+
expect(toggleBtn).toBeTruthy();
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should dispatch an event when a timer arrow button clicked', fakeAsync(() => {
|
|
122
|
+
spyOn(testComponent, 'handleSelectedChange');
|
|
123
|
+
expect(testComponent.handleSelectedChange).not.toHaveBeenCalled();
|
|
124
|
+
|
|
125
|
+
testComponent.showSecondsTimer = true;
|
|
126
|
+
fixture.detectChanges();
|
|
127
|
+
|
|
128
|
+
const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
|
|
129
|
+
'button.owl-dt-control-arrow-button'
|
|
130
|
+
);
|
|
131
|
+
expect(arrowBtns.length).toBe(6);
|
|
132
|
+
|
|
133
|
+
for (let i = 0; i < arrowBtns.length; i++) {
|
|
134
|
+
arrowBtns[i].click();
|
|
135
|
+
fixture.detectChanges();
|
|
136
|
+
flush();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
expect(testComponent.handleSelectedChange).toHaveBeenCalledTimes(6);
|
|
140
|
+
}));
|
|
141
|
+
|
|
142
|
+
it('should dispatch an event when hour12 toggle button clicked', fakeAsync(() => {
|
|
143
|
+
spyOn(testComponent, 'handleSelectedChange');
|
|
144
|
+
expect(testComponent.handleSelectedChange).not.toHaveBeenCalled();
|
|
145
|
+
|
|
146
|
+
testComponent.hour12Timer = true;
|
|
147
|
+
fixture.detectChanges();
|
|
148
|
+
|
|
149
|
+
const toggleBtn = timerElement.querySelector<HTMLButtonElement>(
|
|
150
|
+
'button.owl-dt-timer-hour12-box'
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
toggleBtn.click();
|
|
154
|
+
fixture.detectChanges();
|
|
155
|
+
flush();
|
|
156
|
+
|
|
157
|
+
expect(testComponent.handleSelectedChange).toHaveBeenCalledTimes(1);
|
|
158
|
+
}));
|
|
159
|
+
|
|
160
|
+
it('should add or minus stepHour hours when hour arrow button clicked', fakeAsync(() => {
|
|
161
|
+
expect(timerInstance.stepHour).toBe(1);
|
|
162
|
+
|
|
163
|
+
const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
|
|
164
|
+
'button.owl-dt-control-arrow-button'
|
|
165
|
+
);
|
|
166
|
+
expect(arrowBtns.length).toBe(4);
|
|
167
|
+
|
|
168
|
+
arrowBtns[0].click();
|
|
169
|
+
fixture.detectChanges();
|
|
170
|
+
flush();
|
|
171
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
172
|
+
new Date(2018, JAN, 31, 13, 30, 30)
|
|
173
|
+
);
|
|
174
|
+
|
|
175
|
+
arrowBtns[1].click();
|
|
176
|
+
fixture.detectChanges();
|
|
177
|
+
flush();
|
|
178
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
179
|
+
new Date(2018, JAN, 31, 12, 30, 30)
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
testComponent.stepHour = 2;
|
|
183
|
+
fixture.detectChanges();
|
|
184
|
+
expect(timerInstance.stepHour).toBe(2);
|
|
185
|
+
|
|
186
|
+
arrowBtns[0].click();
|
|
187
|
+
fixture.detectChanges();
|
|
188
|
+
flush();
|
|
189
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
190
|
+
new Date(2018, JAN, 31, 14, 30, 30)
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
arrowBtns[1].click();
|
|
194
|
+
fixture.detectChanges();
|
|
195
|
+
flush();
|
|
196
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
197
|
+
new Date(2018, JAN, 31, 12, 30, 30)
|
|
198
|
+
);
|
|
199
|
+
}));
|
|
200
|
+
|
|
201
|
+
it('should add or minus stepMinute minutes when minute arrow button clicked', fakeAsync(() => {
|
|
202
|
+
expect(timerInstance.stepMinute).toBe(1);
|
|
203
|
+
|
|
204
|
+
const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
|
|
205
|
+
'button.owl-dt-control-arrow-button'
|
|
206
|
+
);
|
|
207
|
+
expect(arrowBtns.length).toBe(4);
|
|
208
|
+
|
|
209
|
+
arrowBtns[2].click();
|
|
210
|
+
fixture.detectChanges();
|
|
211
|
+
flush();
|
|
212
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
213
|
+
new Date(2018, JAN, 31, 12, 31, 30)
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
arrowBtns[3].click();
|
|
217
|
+
fixture.detectChanges();
|
|
218
|
+
flush();
|
|
219
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
220
|
+
new Date(2018, JAN, 31, 12, 30, 30)
|
|
221
|
+
);
|
|
222
|
+
|
|
223
|
+
testComponent.stepMinute = 2;
|
|
224
|
+
fixture.detectChanges();
|
|
225
|
+
expect(timerInstance.stepMinute).toBe(2);
|
|
226
|
+
|
|
227
|
+
arrowBtns[2].click();
|
|
228
|
+
fixture.detectChanges();
|
|
229
|
+
flush();
|
|
230
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
231
|
+
new Date(2018, JAN, 31, 12, 32, 30)
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
arrowBtns[3].click();
|
|
235
|
+
fixture.detectChanges();
|
|
236
|
+
flush();
|
|
237
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
238
|
+
new Date(2018, JAN, 31, 12, 30, 30)
|
|
239
|
+
);
|
|
240
|
+
}));
|
|
241
|
+
|
|
242
|
+
it('should add or minus stepSecond seconds when second arrow button clicked', fakeAsync(() => {
|
|
243
|
+
expect(timerInstance.stepSecond).toBe(1);
|
|
244
|
+
|
|
245
|
+
testComponent.showSecondsTimer = true;
|
|
246
|
+
fixture.detectChanges();
|
|
247
|
+
const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
|
|
248
|
+
'button.owl-dt-control-arrow-button'
|
|
249
|
+
);
|
|
250
|
+
expect(arrowBtns.length).toBe(6);
|
|
251
|
+
|
|
252
|
+
arrowBtns[4].click();
|
|
253
|
+
fixture.detectChanges();
|
|
254
|
+
flush();
|
|
255
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
256
|
+
new Date(2018, JAN, 31, 12, 30, 31)
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
arrowBtns[5].click();
|
|
260
|
+
fixture.detectChanges();
|
|
261
|
+
flush();
|
|
262
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
263
|
+
new Date(2018, JAN, 31, 12, 30, 30)
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
testComponent.stepSecond = 2;
|
|
267
|
+
fixture.detectChanges();
|
|
268
|
+
expect(timerInstance.stepSecond).toBe(2);
|
|
269
|
+
|
|
270
|
+
arrowBtns[4].click();
|
|
271
|
+
fixture.detectChanges();
|
|
272
|
+
flush();
|
|
273
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
274
|
+
new Date(2018, JAN, 31, 12, 30, 32)
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
arrowBtns[5].click();
|
|
278
|
+
fixture.detectChanges();
|
|
279
|
+
flush();
|
|
280
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
281
|
+
new Date(2018, JAN, 31, 12, 30, 30)
|
|
282
|
+
);
|
|
283
|
+
}));
|
|
284
|
+
|
|
285
|
+
it('should toggle between PM and AM when hour12 toggle button clicked', fakeAsync(() => {
|
|
286
|
+
testComponent.hour12Timer = true;
|
|
287
|
+
fixture.detectChanges();
|
|
288
|
+
|
|
289
|
+
const toggleBtn = timerElement.querySelector<HTMLButtonElement>(
|
|
290
|
+
'button.owl-dt-timer-hour12-box'
|
|
291
|
+
);
|
|
292
|
+
expect(toggleBtn.innerHTML).toContain('PM');
|
|
293
|
+
|
|
294
|
+
toggleBtn.click();
|
|
295
|
+
fixture.detectChanges();
|
|
296
|
+
flush();
|
|
297
|
+
|
|
298
|
+
expect(toggleBtn.innerHTML).toContain('AM');
|
|
299
|
+
expect(testComponent.pickerMoment).toEqual(
|
|
300
|
+
new Date(2018, JAN, 31, 0, 30, 30)
|
|
301
|
+
);
|
|
302
|
+
}));
|
|
303
|
+
|
|
304
|
+
it('should disable all down arrow button if pickerMoment equals to minDateTime', () => {
|
|
305
|
+
testComponent.showSecondsTimer = true;
|
|
306
|
+
fixture.detectChanges();
|
|
307
|
+
const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
|
|
308
|
+
'button.owl-dt-control-arrow-button'
|
|
309
|
+
);
|
|
310
|
+
expect(arrowBtns.length).toBe(6);
|
|
311
|
+
|
|
312
|
+
testComponent.pickerMoment = new Date(testComponent.minDateTime);
|
|
313
|
+
fixture.detectChanges();
|
|
314
|
+
|
|
315
|
+
// up arrow buttons
|
|
316
|
+
expect(arrowBtns[0].hasAttribute('disabled')).toBe(false);
|
|
317
|
+
expect(arrowBtns[2].hasAttribute('disabled')).toBe(false);
|
|
318
|
+
expect(arrowBtns[4].hasAttribute('disabled')).toBe(false);
|
|
319
|
+
|
|
320
|
+
// down arrow buttons
|
|
321
|
+
expect(arrowBtns[1].hasAttribute('disabled')).toBe(true);
|
|
322
|
+
expect(arrowBtns[3].hasAttribute('disabled')).toBe(true);
|
|
323
|
+
expect(arrowBtns[5].hasAttribute('disabled')).toBe(true);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
it('should disable all up arrow button if pickerMoment equals to maxDateTime', () => {
|
|
327
|
+
testComponent.showSecondsTimer = true;
|
|
328
|
+
fixture.detectChanges();
|
|
329
|
+
const arrowBtns = timerElement.querySelectorAll<HTMLButtonElement>(
|
|
330
|
+
'button.owl-dt-control-arrow-button'
|
|
331
|
+
);
|
|
332
|
+
expect(arrowBtns.length).toBe(6);
|
|
333
|
+
|
|
334
|
+
testComponent.pickerMoment = new Date(testComponent.maxDateTime);
|
|
335
|
+
fixture.detectChanges();
|
|
336
|
+
|
|
337
|
+
// up arrow buttons
|
|
338
|
+
expect(arrowBtns[0].hasAttribute('disabled')).toBe(true);
|
|
339
|
+
expect(arrowBtns[2].hasAttribute('disabled')).toBe(true);
|
|
340
|
+
expect(arrowBtns[4].hasAttribute('disabled')).toBe(true);
|
|
341
|
+
|
|
342
|
+
// down arrow buttons
|
|
343
|
+
expect(arrowBtns[1].hasAttribute('disabled')).toBe(false);
|
|
344
|
+
expect(arrowBtns[3].hasAttribute('disabled')).toBe(false);
|
|
345
|
+
expect(arrowBtns[5].hasAttribute('disabled')).toBe(false);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
it('should not reformat input text while field is focused', fakeAsync(() => {
|
|
349
|
+
const timeCells = timerElement.querySelectorAll<HTMLInputElement>('.owl-dt-timer-input');
|
|
350
|
+
|
|
351
|
+
dispatchFakeEvent(timeCells[0], 'focusin');
|
|
352
|
+
timeCells[0].value = '5';
|
|
353
|
+
dispatchFakeEvent(timeCells[0], 'input');
|
|
354
|
+
setTimeout(() => { }, 1000);
|
|
355
|
+
|
|
356
|
+
timeCells[1].value = '8';
|
|
357
|
+
dispatchFakeEvent(timeCells[1], 'input');
|
|
358
|
+
setTimeout(() => { }, 1000);
|
|
359
|
+
|
|
360
|
+
fixture.detectChanges();
|
|
361
|
+
|
|
362
|
+
expect(timeCells[0].value).toEqual('5');
|
|
363
|
+
expect(timeCells[1].value).toEqual('8');
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
flush();
|
|
367
|
+
}));
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
@Component({
|
|
372
|
+
standalone: false,
|
|
373
|
+
template: `
|
|
374
|
+
<owl-date-time-timer
|
|
375
|
+
[hour12Timer]="hour12Timer"
|
|
376
|
+
[showSecondsTimer]="showSecondsTimer"
|
|
377
|
+
[pickerMoment]="pickerMoment"
|
|
378
|
+
[stepHour]="stepHour"
|
|
379
|
+
[stepMinute]="stepMinute"
|
|
380
|
+
[stepSecond]="stepSecond"
|
|
381
|
+
[minDateTime]="minDateTime"
|
|
382
|
+
[maxDateTime]="maxDateTime"
|
|
383
|
+
(selectedChange)="handleSelectedChange($event)"></owl-date-time-timer>
|
|
384
|
+
`
|
|
385
|
+
})
|
|
386
|
+
class StandardTimerComponent {
|
|
387
|
+
stepHour = 1;
|
|
388
|
+
stepMinute = 1;
|
|
389
|
+
stepSecond = 1;
|
|
390
|
+
hour12Timer = false;
|
|
391
|
+
showSecondsTimer = false;
|
|
392
|
+
pickerMoment = new Date(2018, JAN, 31, 12, 30, 30);
|
|
393
|
+
minDateTime = new Date(2018, JAN, 29, 12, 30, 30);
|
|
394
|
+
maxDateTime = new Date(2018, FEB, 1, 12, 30, 30);
|
|
395
|
+
|
|
396
|
+
handleSelectedChange(val: Date) {
|
|
397
|
+
this.pickerMoment = val;
|
|
398
|
+
}
|
|
399
|
+
}
|