@angular-wave/angular.ts 0.0.27 → 0.0.29
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/README.md +1 -2
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/e2e/unit.spec.ts +2 -1
- package/index.html +6 -6
- package/package.json +1 -1
- package/src/core/pubsub.js +329 -0
- package/src/router/common/trace.js +6 -6
- package/src/router/directives/state-directives.js +74 -74
- package/src/router/directives/view-directive.js +21 -21
- package/src/router/hooks/core-resolvables.js +12 -11
- package/src/router/hooks/ignored-transition.js +1 -1
- package/src/router/hooks/lazy-load.js +40 -41
- package/src/router/hooks/redirect-to.js +32 -29
- package/src/router/hooks/update-globals.js +1 -1
- package/src/router/hooks/url.js +33 -24
- package/src/router/hooks/views.js +21 -20
- package/src/router/index.js +12 -12
- package/src/router/injectables.js +3 -3
- package/src/router/params/param-factory.js +17 -0
- package/src/router/router.js +75 -10
- package/src/router/services.js +4 -8
- package/src/router/state/state-builder.js +1 -0
- package/src/router/state/state-queue-manager.js +5 -4
- package/src/router/state/state-registry.js +63 -7
- package/src/router/state/state-service.js +47 -51
- package/src/router/state/views.js +4 -4
- package/src/router/state-filters.js +0 -2
- package/src/router/state-provider.js +0 -2
- package/src/router/template-factory.js +4 -4
- package/src/router/transition/hook-builder.js +2 -2
- package/src/router/transition/transition-hook.js +2 -1
- package/src/router/transition/transition-service.js +11 -18
- package/src/router/transition/transition.js +28 -25
- package/src/router/url/url-config.js +1 -49
- package/src/router/url/url-matcher-factory.js +10 -51
- package/src/router/url/url-router.js +31 -17
- package/src/router/url/url-rule.js +9 -13
- package/src/router/url/url-rules.js +3 -3
- package/src/router/url/url-service.js +22 -18
- package/src/router/view/view.js +67 -67
- package/src/services/browser.js +1 -5
- package/src/shared/hof.js +1 -1
- package/test/angular.spec.js +1 -0
- package/test/aria/aria.spec.js +2 -1
- package/test/core/pubsub.spec.js +387 -0
- package/test/directive/bind.spec.js +2 -1
- package/test/directive/boolean.spec.js +4 -2
- package/test/directive/change.spec.js +1 -1
- package/test/directive/class.spec.js +1 -0
- package/test/directive/click.spec.js +2 -1
- package/test/directive/cloak.spec.js +1 -2
- package/test/directive/{constoller.spec.js → controller.spec.js} +1 -0
- package/test/directive/element-style.spec.js +1 -0
- package/test/directive/event.spec.js +1 -1
- package/test/directive/href.spec.js +2 -1
- package/test/directive/init.spec.js +1 -0
- package/test/directive/input.spec.js +200 -285
- package/test/directive/list.spec.js +2 -1
- package/test/directive/model.spec.js +1 -0
- package/test/directive/non-bindable.spec.js +2 -1
- package/test/directive/script.spec.js +1 -0
- package/test/directive/scrset.spec.js +2 -1
- package/test/directive/show-hide.spec.js +1 -0
- package/test/directive/src.spec.js +2 -1
- package/test/directive/style.spec.js +1 -0
- package/test/directive/switch.spec.js +2 -1
- package/test/directive/validators.spec.js +1 -1
- package/test/module-test.html +5 -5
- package/test/original-test.html +3 -3
- package/test/router/services.spec.js +1 -1
- package/test/router/state-directives.spec.js +72 -80
- package/test/router/state-filter.spec.js +6 -4
- package/test/router/state.spec.js +15 -13
- package/test/router/template-factory.spec.js +4 -4
- package/test/router/url-matcher-factory.spec.js +2 -2
- package/test/router/view-directive.spec.js +165 -163
- package/test/router/view-hook.spec.js +4 -4
- package/test/router/view-scroll.spec.js +15 -15
- package/test/router/view.spec.js +3 -3
- package/types/router/core/common/coreservices.d.ts +2 -3
- package/types/router/core/globals.d.ts +1 -4
- package/types/router/core/interface.d.ts +2 -8
- package/types/router/core/params/paramTypes.d.ts +0 -1
- package/types/router/core/router.d.ts +2 -3
- package/types/router/core/state/interface.d.ts +6 -6
- package/types/router/core/state/stateQueueManager.d.ts +1 -3
- package/types/router/core/state/stateRegistry.d.ts +1 -2
- package/types/router/core/state/stateService.d.ts +5 -6
- package/types/router/core/transition/interface.d.ts +4 -4
- package/types/router/core/transition/transitionService.d.ts +1 -2
- package/types/router/core/url/urlConfig.d.ts +1 -2
- package/types/router/core/url/urlRules.d.ts +1 -2
- package/types/router/core/url/urlService.d.ts +1 -2
- package/types/router/core/view/interface.d.ts +2 -2
- package/types/router/core/view/view.d.ts +16 -16
- package/types/router/directives/viewDirective.d.ts +3 -3
- package/types/router/interface.d.ts +4 -4
- package/types/router/locationServices.d.ts +0 -1
- package/types/router/stateProvider.d.ts +3 -3
- package/types/router/statebuilders/views.d.ts +1 -1
- package/types/router/templateFactory.d.ts +2 -2
- package/types/router/viewScroll.d.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { publishExternalAPI } from "../../src/public";
|
|
2
2
|
import { createInjector } from "../../src/injector";
|
|
3
|
-
import { jqLite } from "../../src/jqLite";
|
|
3
|
+
import { dealoc, jqLite } from "../../src/jqLite";
|
|
4
4
|
import {
|
|
5
5
|
EMAIL_REGEXP,
|
|
6
6
|
ISO_DATE_REGEXP,
|
|
@@ -11,10 +11,11 @@ import { forEach } from "../../src/shared/utils";
|
|
|
11
11
|
describe("input", () => {
|
|
12
12
|
let $compile;
|
|
13
13
|
let scope;
|
|
14
|
+
let inputElm;
|
|
14
15
|
|
|
15
16
|
beforeEach(() => {
|
|
16
17
|
publishExternalAPI().decorator("$exceptionHandler", function () {
|
|
17
|
-
return (exception
|
|
18
|
+
return (exception) => {
|
|
18
19
|
throw new Error(exception.message);
|
|
19
20
|
};
|
|
20
21
|
});
|
|
@@ -24,8 +25,12 @@ describe("input", () => {
|
|
|
24
25
|
});
|
|
25
26
|
});
|
|
26
27
|
|
|
28
|
+
afterEach(() => {
|
|
29
|
+
dealoc(inputElm);
|
|
30
|
+
});
|
|
31
|
+
|
|
27
32
|
it("should bind to a model", () => {
|
|
28
|
-
|
|
33
|
+
inputElm = $compile(
|
|
29
34
|
'<input type="text" ng-model="name" name="alias" ng-change="change()" />',
|
|
30
35
|
)(scope);
|
|
31
36
|
|
|
@@ -35,7 +40,7 @@ describe("input", () => {
|
|
|
35
40
|
});
|
|
36
41
|
|
|
37
42
|
it('should update the model on "blur" event', () => {
|
|
38
|
-
|
|
43
|
+
inputElm = $compile(
|
|
39
44
|
'<input type="text" ng-model="name" name="alias" ng-change="change()" />',
|
|
40
45
|
)(scope);
|
|
41
46
|
inputElm[0].setAttribute("value", "adam");
|
|
@@ -71,7 +76,7 @@ describe("input", () => {
|
|
|
71
76
|
it('should not update the model between "compositionstart" and "compositionend"', () => {
|
|
72
77
|
//$sniffer.android = false;
|
|
73
78
|
|
|
74
|
-
|
|
79
|
+
inputElm = $compile(
|
|
75
80
|
'<input type="text" ng-model="name" name="alias"" />',
|
|
76
81
|
)(scope);
|
|
77
82
|
inputElm[0].setAttribute("value", "a");
|
|
@@ -90,7 +95,7 @@ describe("input", () => {
|
|
|
90
95
|
describe("interpolated names", () => {
|
|
91
96
|
it("should interpolate input names", () => {
|
|
92
97
|
scope.nameID = "47";
|
|
93
|
-
|
|
98
|
+
inputElm = $compile(
|
|
94
99
|
'<form name="form"><input type="text" ng-model="name" name="name{{nameID}}" /></form>',
|
|
95
100
|
)(scope);
|
|
96
101
|
expect(scope.form.name47.$pristine).toBeTruthy();
|
|
@@ -101,7 +106,7 @@ describe("input", () => {
|
|
|
101
106
|
|
|
102
107
|
it("should rename form controls in form when interpolated name changes", () => {
|
|
103
108
|
scope.nameID = "A";
|
|
104
|
-
|
|
109
|
+
inputElm = $compile(
|
|
105
110
|
'<form name="form"><input type="text" ng-model="name" name="name{{nameID}}" /></form>',
|
|
106
111
|
)(scope);
|
|
107
112
|
expect(scope.form.nameA.$name).toBe("nameA");
|
|
@@ -115,7 +120,7 @@ describe("input", () => {
|
|
|
115
120
|
|
|
116
121
|
it("should rename form controls in null form when interpolated name changes", () => {
|
|
117
122
|
scope.nameID = "A";
|
|
118
|
-
|
|
123
|
+
inputElm = $compile(
|
|
119
124
|
'<input type="text" ng-model="name" name="name{{nameID}}" />',
|
|
120
125
|
)(scope);
|
|
121
126
|
const model = inputElm.controller("ngModel");
|
|
@@ -132,7 +137,7 @@ describe("input", () => {
|
|
|
132
137
|
|
|
133
138
|
beforeEach(() => {
|
|
134
139
|
assertBrowserSupportsChangeEvent = function (inputEventSupported) {
|
|
135
|
-
|
|
140
|
+
inputElm = $compile(
|
|
136
141
|
'<input type="text" ng-model="name" name="alias" />',
|
|
137
142
|
)(scope);
|
|
138
143
|
|
|
@@ -157,7 +162,7 @@ describe("input", () => {
|
|
|
157
162
|
|
|
158
163
|
describe('"keydown", "paste", "cut" and "drop" events', () => {
|
|
159
164
|
it('should update the model on "paste" event if the input value changes', () => {
|
|
160
|
-
|
|
165
|
+
inputElm = $compile(
|
|
161
166
|
'<input type="text" ng-model="name" name="alias" ng-change="change()" />',
|
|
162
167
|
)(scope);
|
|
163
168
|
|
|
@@ -170,7 +175,7 @@ describe("input", () => {
|
|
|
170
175
|
});
|
|
171
176
|
|
|
172
177
|
it('should update the model on "drop" event if the input value changes', () => {
|
|
173
|
-
|
|
178
|
+
inputElm = $compile(
|
|
174
179
|
'<input type="text" ng-model="name" name="alias" ng-change="change()" />',
|
|
175
180
|
)(scope);
|
|
176
181
|
|
|
@@ -183,7 +188,7 @@ describe("input", () => {
|
|
|
183
188
|
});
|
|
184
189
|
|
|
185
190
|
it('should update the model on "cut" event', () => {
|
|
186
|
-
|
|
191
|
+
inputElm = $compile(
|
|
187
192
|
'<input type="text" ng-model="name" name="alias" ng-change="change()" />',
|
|
188
193
|
)(scope);
|
|
189
194
|
|
|
@@ -193,9 +198,7 @@ describe("input", () => {
|
|
|
193
198
|
});
|
|
194
199
|
|
|
195
200
|
it("should cancel the delayed dirty if a change occurs", () => {
|
|
196
|
-
|
|
197
|
-
scope,
|
|
198
|
-
);
|
|
201
|
+
inputElm = $compile('<input type="text" ng-model="name" />')(scope);
|
|
199
202
|
const ctrl = inputElm.controller("ngModel");
|
|
200
203
|
|
|
201
204
|
inputElm[0].dispatchEvent(
|
|
@@ -213,7 +216,7 @@ describe("input", () => {
|
|
|
213
216
|
|
|
214
217
|
describe("ngTrim", () => {
|
|
215
218
|
it("should update the model and trim the value", () => {
|
|
216
|
-
|
|
219
|
+
inputElm = $compile(
|
|
217
220
|
'<input type="text" ng-model="name" name="alias" ng-change="change()" />',
|
|
218
221
|
)(scope);
|
|
219
222
|
|
|
@@ -223,7 +226,7 @@ describe("input", () => {
|
|
|
223
226
|
});
|
|
224
227
|
|
|
225
228
|
it("should update the model and not trim the value", () => {
|
|
226
|
-
|
|
229
|
+
inputElm = $compile(
|
|
227
230
|
'<input type="text" ng-model="name" name="alias" ng-trim="false" />',
|
|
228
231
|
)(scope);
|
|
229
232
|
|
|
@@ -234,7 +237,7 @@ describe("input", () => {
|
|
|
234
237
|
});
|
|
235
238
|
|
|
236
239
|
it("should allow complex reference binding", () => {
|
|
237
|
-
|
|
240
|
+
inputElm = $compile(
|
|
238
241
|
'<input type="text" ng-model="obj[\'abc\'].name"/>',
|
|
239
242
|
)(scope);
|
|
240
243
|
|
|
@@ -243,9 +246,9 @@ describe("input", () => {
|
|
|
243
246
|
});
|
|
244
247
|
|
|
245
248
|
it("should ignore input without ngModel directive", () => {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
)
|
|
249
|
+
inputElm = $compile('<input type="text" name="whatever" required />')(
|
|
250
|
+
scope,
|
|
251
|
+
);
|
|
249
252
|
|
|
250
253
|
inputElm[0].setAttribute("value", "");
|
|
251
254
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -257,16 +260,14 @@ describe("input", () => {
|
|
|
257
260
|
|
|
258
261
|
it("should report error on assignment error", () => {
|
|
259
262
|
expect(() => {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
)
|
|
263
|
+
inputElm = $compile('<input type="text" ng-model="throw \'\'">')(
|
|
264
|
+
scope,
|
|
265
|
+
);
|
|
263
266
|
}).toThrowError(/Syntax Error/);
|
|
264
267
|
});
|
|
265
268
|
|
|
266
269
|
it("should render as blank if null", () => {
|
|
267
|
-
|
|
268
|
-
scope,
|
|
269
|
-
);
|
|
270
|
+
inputElm = $compile('<input type="text" ng-model="age" />')(scope);
|
|
270
271
|
|
|
271
272
|
scope.$apply("age = null");
|
|
272
273
|
|
|
@@ -275,18 +276,14 @@ describe("input", () => {
|
|
|
275
276
|
});
|
|
276
277
|
|
|
277
278
|
it("should render 0 even if it is a number", () => {
|
|
278
|
-
|
|
279
|
-
scope,
|
|
280
|
-
);
|
|
279
|
+
inputElm = $compile('<input type="text" ng-model="value" />')(scope);
|
|
281
280
|
scope.$apply("value = 0");
|
|
282
281
|
|
|
283
282
|
expect(inputElm.val()).toBe("0");
|
|
284
283
|
});
|
|
285
284
|
|
|
286
285
|
it("should render the $viewValue when $modelValue is empty", () => {
|
|
287
|
-
|
|
288
|
-
scope,
|
|
289
|
-
);
|
|
286
|
+
inputElm = $compile('<input type="text" ng-model="value" />')(scope);
|
|
290
287
|
|
|
291
288
|
const ctrl = inputElm.controller("ngModel");
|
|
292
289
|
|
|
@@ -305,9 +302,7 @@ describe("input", () => {
|
|
|
305
302
|
describe("month", () => {
|
|
306
303
|
// IN ANGULAR.JS month types were converted to Date object. This is not standard behavior
|
|
307
304
|
it("should allow a String object in format 'YYYY-MM'", () => {
|
|
308
|
-
|
|
309
|
-
scope,
|
|
310
|
-
);
|
|
305
|
+
inputElm = $compile('<input type="month" ng-model="january"/>')(scope);
|
|
311
306
|
|
|
312
307
|
scope.$apply(() => {
|
|
313
308
|
scope.january = "2013-01";
|
|
@@ -317,9 +312,7 @@ describe("input", () => {
|
|
|
317
312
|
});
|
|
318
313
|
|
|
319
314
|
it("should throw if the model is a Date object", () => {
|
|
320
|
-
|
|
321
|
-
scope,
|
|
322
|
-
);
|
|
315
|
+
inputElm = $compile('<input type="month" ng-model="march"/>')(scope);
|
|
323
316
|
|
|
324
317
|
expect(() => {
|
|
325
318
|
scope.$apply(() => {
|
|
@@ -329,9 +322,7 @@ describe("input", () => {
|
|
|
329
322
|
});
|
|
330
323
|
|
|
331
324
|
it("should throw if the model is a Invalid string", () => {
|
|
332
|
-
|
|
333
|
-
scope,
|
|
334
|
-
);
|
|
325
|
+
inputElm = $compile('<input type="month" ng-model="march"/>')(scope);
|
|
335
326
|
|
|
336
327
|
expect(() => {
|
|
337
328
|
scope.$apply(() => {
|
|
@@ -341,9 +332,7 @@ describe("input", () => {
|
|
|
341
332
|
});
|
|
342
333
|
|
|
343
334
|
it("should not change the model if the input is an invalid month string", () => {
|
|
344
|
-
|
|
345
|
-
scope,
|
|
346
|
-
);
|
|
335
|
+
inputElm = $compile('<input type="month" ng-model="value"/>')(scope);
|
|
347
336
|
|
|
348
337
|
scope.$apply(() => {
|
|
349
338
|
scope.value = "2013-01";
|
|
@@ -358,9 +347,7 @@ describe("input", () => {
|
|
|
358
347
|
});
|
|
359
348
|
|
|
360
349
|
it("should render as blank if null", () => {
|
|
361
|
-
|
|
362
|
-
scope,
|
|
363
|
-
);
|
|
350
|
+
inputElm = $compile('<input type="month" ng-model="test" />')(scope);
|
|
364
351
|
|
|
365
352
|
scope.$apply("test = null");
|
|
366
353
|
|
|
@@ -369,9 +356,7 @@ describe("input", () => {
|
|
|
369
356
|
});
|
|
370
357
|
|
|
371
358
|
it("should come up blank when no value specified", () => {
|
|
372
|
-
|
|
373
|
-
scope,
|
|
374
|
-
);
|
|
359
|
+
inputElm = $compile('<input type="month" ng-model="test" />')(scope);
|
|
375
360
|
|
|
376
361
|
expect(inputElm.val()).toBe("");
|
|
377
362
|
|
|
@@ -382,9 +367,7 @@ describe("input", () => {
|
|
|
382
367
|
});
|
|
383
368
|
|
|
384
369
|
it("should parse empty string to null", () => {
|
|
385
|
-
|
|
386
|
-
scope,
|
|
387
|
-
);
|
|
370
|
+
inputElm = $compile('<input type="month" ng-model="test" />')(scope);
|
|
388
371
|
|
|
389
372
|
inputElm[0].setAttribute("value", "");
|
|
390
373
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -393,9 +376,7 @@ describe("input", () => {
|
|
|
393
376
|
});
|
|
394
377
|
|
|
395
378
|
it("should set scope to a string value", () => {
|
|
396
|
-
|
|
397
|
-
scope,
|
|
398
|
-
);
|
|
379
|
+
inputElm = $compile('<input type="month" ng-model="value" />')(scope);
|
|
399
380
|
|
|
400
381
|
inputElm[0].setAttribute("value", "2013-07");
|
|
401
382
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -515,7 +496,7 @@ describe("input", () => {
|
|
|
515
496
|
|
|
516
497
|
describe("week", () => {
|
|
517
498
|
it("should throw if model is a Date object", () => {
|
|
518
|
-
|
|
499
|
+
inputElm = $compile('<input type="week" ng-model="secondWeek"/>')(
|
|
519
500
|
scope,
|
|
520
501
|
);
|
|
521
502
|
|
|
@@ -527,7 +508,7 @@ describe("input", () => {
|
|
|
527
508
|
});
|
|
528
509
|
|
|
529
510
|
it("should set the view if the model is a valid String object", () => {
|
|
530
|
-
|
|
511
|
+
inputElm = $compile('<input type="week" ng-model="secondWeek"/>')(
|
|
531
512
|
scope,
|
|
532
513
|
);
|
|
533
514
|
|
|
@@ -539,9 +520,9 @@ describe("input", () => {
|
|
|
539
520
|
});
|
|
540
521
|
|
|
541
522
|
it("should set scope to a string value", () => {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
)
|
|
523
|
+
inputElm = $compile('<input type="week" ng-model="secondWeek" />')(
|
|
524
|
+
scope,
|
|
525
|
+
);
|
|
545
526
|
|
|
546
527
|
scope.$apply(() => {
|
|
547
528
|
scope.secondWeek = "2013-W02";
|
|
@@ -556,7 +537,7 @@ describe("input", () => {
|
|
|
556
537
|
});
|
|
557
538
|
|
|
558
539
|
it("should set the model undefined if the input is an invalid week string", () => {
|
|
559
|
-
|
|
540
|
+
inputElm = $compile('<input type="week" ng-model="secondWeek"/>')(
|
|
560
541
|
scope,
|
|
561
542
|
);
|
|
562
543
|
|
|
@@ -574,9 +555,7 @@ describe("input", () => {
|
|
|
574
555
|
});
|
|
575
556
|
|
|
576
557
|
it("should render as blank if null", () => {
|
|
577
|
-
|
|
578
|
-
scope,
|
|
579
|
-
);
|
|
558
|
+
inputElm = $compile('<input type="week" ng-model="test" />')(scope);
|
|
580
559
|
|
|
581
560
|
scope.$apply("test = null");
|
|
582
561
|
|
|
@@ -585,9 +564,7 @@ describe("input", () => {
|
|
|
585
564
|
});
|
|
586
565
|
|
|
587
566
|
it("should come up blank when no value specified", () => {
|
|
588
|
-
|
|
589
|
-
scope,
|
|
590
|
-
);
|
|
567
|
+
inputElm = $compile('<input type="week" ng-model="test" />')(scope);
|
|
591
568
|
|
|
592
569
|
expect(inputElm.val()).toBe("");
|
|
593
570
|
|
|
@@ -598,9 +575,7 @@ describe("input", () => {
|
|
|
598
575
|
});
|
|
599
576
|
|
|
600
577
|
it("should parse empty string to null", () => {
|
|
601
|
-
|
|
602
|
-
scope,
|
|
603
|
-
);
|
|
578
|
+
inputElm = $compile('<input type="week" ng-model="test" />')(scope);
|
|
604
579
|
|
|
605
580
|
scope.$apply(() => {
|
|
606
581
|
scope.test = "2013-W02";
|
|
@@ -722,7 +697,7 @@ describe("input", () => {
|
|
|
722
697
|
|
|
723
698
|
describe("datetime-local", () => {
|
|
724
699
|
it("should throw if model is a Date object", () => {
|
|
725
|
-
|
|
700
|
+
inputElm = $compile(
|
|
726
701
|
'<input type="datetime-local" ng-model="lunchtime"/>',
|
|
727
702
|
)(scope);
|
|
728
703
|
|
|
@@ -734,7 +709,7 @@ describe("input", () => {
|
|
|
734
709
|
});
|
|
735
710
|
|
|
736
711
|
it("should set the view if the model if a valid String.", () => {
|
|
737
|
-
|
|
712
|
+
inputElm = $compile(
|
|
738
713
|
'<input type="datetime-local" ng-model="halfSecondToNextYear"/>',
|
|
739
714
|
)(scope);
|
|
740
715
|
|
|
@@ -746,7 +721,7 @@ describe("input", () => {
|
|
|
746
721
|
});
|
|
747
722
|
|
|
748
723
|
it("should bind to the model if a valid String.", () => {
|
|
749
|
-
|
|
724
|
+
inputElm = $compile(
|
|
750
725
|
'<input type="datetime-local" ng-model="halfSecondToNextYear"/>',
|
|
751
726
|
)(scope);
|
|
752
727
|
|
|
@@ -758,7 +733,7 @@ describe("input", () => {
|
|
|
758
733
|
});
|
|
759
734
|
|
|
760
735
|
it("should set the model null if the view is invalid", () => {
|
|
761
|
-
|
|
736
|
+
inputElm = $compile(
|
|
762
737
|
'<input type="datetime-local" ng-model="breakMe"/>',
|
|
763
738
|
)(scope);
|
|
764
739
|
|
|
@@ -777,9 +752,9 @@ describe("input", () => {
|
|
|
777
752
|
});
|
|
778
753
|
|
|
779
754
|
it("should render as blank if null", () => {
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
)
|
|
755
|
+
inputElm = $compile('<input type="datetime-local" ng-model="test" />')(
|
|
756
|
+
scope,
|
|
757
|
+
);
|
|
783
758
|
|
|
784
759
|
scope.$apply("test = null");
|
|
785
760
|
|
|
@@ -788,9 +763,9 @@ describe("input", () => {
|
|
|
788
763
|
});
|
|
789
764
|
|
|
790
765
|
it("should come up blank when no value specified", () => {
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
)
|
|
766
|
+
inputElm = $compile('<input type="datetime-local" ng-model="test" />')(
|
|
767
|
+
scope,
|
|
768
|
+
);
|
|
794
769
|
|
|
795
770
|
expect(inputElm.val()).toBe("");
|
|
796
771
|
|
|
@@ -801,9 +776,9 @@ describe("input", () => {
|
|
|
801
776
|
});
|
|
802
777
|
|
|
803
778
|
it("should parse empty string to null", () => {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
)
|
|
779
|
+
inputElm = $compile('<input type="datetime-local" ng-model="test" />')(
|
|
780
|
+
scope,
|
|
781
|
+
);
|
|
807
782
|
|
|
808
783
|
scope.$apply(() => {
|
|
809
784
|
scope.test = "2013-12-16T11:30";
|
|
@@ -933,7 +908,7 @@ describe("input", () => {
|
|
|
933
908
|
|
|
934
909
|
it("should validate even if max value changes on-the-fly", () => {
|
|
935
910
|
scope.max = "2013-01-01T01:02:00";
|
|
936
|
-
|
|
911
|
+
inputElm = $compile(
|
|
937
912
|
'<input type="datetime-local" ng-model="value" name="alias" max="{{max}}" />',
|
|
938
913
|
)(scope);
|
|
939
914
|
|
|
@@ -953,7 +928,7 @@ describe("input", () => {
|
|
|
953
928
|
|
|
954
929
|
it("should validate even if min value changes on-the-fly", () => {
|
|
955
930
|
scope.min = "2013-01-01T01:02:00";
|
|
956
|
-
|
|
931
|
+
inputElm = $compile(
|
|
957
932
|
'<input type="datetime-local" ng-model="value" name="alias" min="{{min}}" />',
|
|
958
933
|
)(scope);
|
|
959
934
|
|
|
@@ -973,7 +948,7 @@ describe("input", () => {
|
|
|
973
948
|
|
|
974
949
|
it("should validate even if ng-max value changes on-the-fly", () => {
|
|
975
950
|
scope.max = "2013-01-01T01:02:00";
|
|
976
|
-
|
|
951
|
+
inputElm = $compile(
|
|
977
952
|
'<input type="datetime-local" ng-model="value" name="alias" ng-max="max" />',
|
|
978
953
|
)(scope);
|
|
979
954
|
|
|
@@ -993,7 +968,7 @@ describe("input", () => {
|
|
|
993
968
|
|
|
994
969
|
it("should validate even if ng-min value changes on-the-fly", () => {
|
|
995
970
|
scope.min = "2013-01-01T01:02:00";
|
|
996
|
-
|
|
971
|
+
inputElm = $compile(
|
|
997
972
|
'<input type="datetime-local" ng-model="value" name="alias" ng-min="min" />',
|
|
998
973
|
)(scope);
|
|
999
974
|
|
|
@@ -1014,9 +989,7 @@ describe("input", () => {
|
|
|
1014
989
|
|
|
1015
990
|
describe("time", () => {
|
|
1016
991
|
it("should throw if model is a Date object", () => {
|
|
1017
|
-
|
|
1018
|
-
scope,
|
|
1019
|
-
);
|
|
992
|
+
inputElm = $compile('<input type="time" ng-model="lunchtime"/>')(scope);
|
|
1020
993
|
expect(() => {
|
|
1021
994
|
scope.$apply(() => {
|
|
1022
995
|
scope.lunchtime = new Date(1970, 0, 1, 15, 41, 0, 500);
|
|
@@ -1025,9 +998,9 @@ describe("input", () => {
|
|
|
1025
998
|
});
|
|
1026
999
|
|
|
1027
1000
|
it("should set the view if the model is a valid String object.", () => {
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
)
|
|
1001
|
+
inputElm = $compile('<input type="time" ng-model="threeFortyOnePm"/>')(
|
|
1002
|
+
scope,
|
|
1003
|
+
);
|
|
1031
1004
|
|
|
1032
1005
|
scope.$apply(() => {
|
|
1033
1006
|
scope.threeFortyOnePm = "15:41:00.500";
|
|
@@ -1037,9 +1010,9 @@ describe("input", () => {
|
|
|
1037
1010
|
});
|
|
1038
1011
|
|
|
1039
1012
|
it("should bind to mode if a valid String object.", () => {
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
)
|
|
1013
|
+
inputElm = $compile('<input type="time" ng-model="threeFortyOnePm"/>')(
|
|
1014
|
+
scope,
|
|
1015
|
+
);
|
|
1043
1016
|
|
|
1044
1017
|
inputElm[0].value = "15:41:00.500";
|
|
1045
1018
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -1049,9 +1022,7 @@ describe("input", () => {
|
|
|
1049
1022
|
});
|
|
1050
1023
|
|
|
1051
1024
|
it("should set the model to null if the view is invalid", () => {
|
|
1052
|
-
|
|
1053
|
-
scope,
|
|
1054
|
-
);
|
|
1025
|
+
inputElm = $compile('<input type="time" ng-model="breakMe"/>')(scope);
|
|
1055
1026
|
|
|
1056
1027
|
scope.$apply(() => {
|
|
1057
1028
|
scope.breakMe = "16:25:00.000";
|
|
@@ -1066,9 +1037,7 @@ describe("input", () => {
|
|
|
1066
1037
|
});
|
|
1067
1038
|
|
|
1068
1039
|
it("should set blank if null", () => {
|
|
1069
|
-
|
|
1070
|
-
scope,
|
|
1071
|
-
);
|
|
1040
|
+
inputElm = $compile('<input type="time" ng-model="test" />')(scope);
|
|
1072
1041
|
|
|
1073
1042
|
scope.$apply("test = null");
|
|
1074
1043
|
|
|
@@ -1077,9 +1046,7 @@ describe("input", () => {
|
|
|
1077
1046
|
});
|
|
1078
1047
|
|
|
1079
1048
|
it("should set blank when no value specified", () => {
|
|
1080
|
-
|
|
1081
|
-
scope,
|
|
1082
|
-
);
|
|
1049
|
+
inputElm = $compile('<input type="time" ng-model="test" />')(scope);
|
|
1083
1050
|
|
|
1084
1051
|
expect(inputElm.val()).toBe("");
|
|
1085
1052
|
|
|
@@ -1090,9 +1057,7 @@ describe("input", () => {
|
|
|
1090
1057
|
});
|
|
1091
1058
|
|
|
1092
1059
|
it("should parse empty string to null", () => {
|
|
1093
|
-
|
|
1094
|
-
scope,
|
|
1095
|
-
);
|
|
1060
|
+
inputElm = $compile('<input type="time" ng-model="test" />')(scope);
|
|
1096
1061
|
|
|
1097
1062
|
scope.$apply(() => {
|
|
1098
1063
|
scope.test = "16:25:00";
|
|
@@ -1104,9 +1069,7 @@ describe("input", () => {
|
|
|
1104
1069
|
});
|
|
1105
1070
|
|
|
1106
1071
|
it("should allow to specify the milliseconds", () => {
|
|
1107
|
-
|
|
1108
|
-
scope,
|
|
1109
|
-
);
|
|
1072
|
+
inputElm = $compile('<input type="time" ng-model="value"" />')(scope);
|
|
1110
1073
|
|
|
1111
1074
|
inputElm[0].value = "01:02:03.500";
|
|
1112
1075
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -1114,9 +1077,7 @@ describe("input", () => {
|
|
|
1114
1077
|
});
|
|
1115
1078
|
|
|
1116
1079
|
it("should allow to specify single digit milliseconds", () => {
|
|
1117
|
-
|
|
1118
|
-
scope,
|
|
1119
|
-
);
|
|
1080
|
+
inputElm = $compile('<input type="time" ng-model="value"" />')(scope);
|
|
1120
1081
|
|
|
1121
1082
|
inputElm[0].value = "01:02:03.4";
|
|
1122
1083
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -1124,9 +1085,7 @@ describe("input", () => {
|
|
|
1124
1085
|
});
|
|
1125
1086
|
|
|
1126
1087
|
it("should allow to specify the seconds", () => {
|
|
1127
|
-
|
|
1128
|
-
scope,
|
|
1129
|
-
);
|
|
1088
|
+
inputElm = $compile('<input type="time" ng-model="value"" />')(scope);
|
|
1130
1089
|
|
|
1131
1090
|
inputElm[0].value = "01:02:03";
|
|
1132
1091
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -1223,7 +1182,7 @@ describe("input", () => {
|
|
|
1223
1182
|
|
|
1224
1183
|
it("should validate even if max value changes on-the-fly", () => {
|
|
1225
1184
|
scope.max = "04:02:00";
|
|
1226
|
-
|
|
1185
|
+
inputElm = $compile(
|
|
1227
1186
|
'<input type="time" ng-model="value" name="alias" max="{{max}}" />',
|
|
1228
1187
|
)(scope);
|
|
1229
1188
|
|
|
@@ -1239,7 +1198,7 @@ describe("input", () => {
|
|
|
1239
1198
|
|
|
1240
1199
|
it("should validate even if min value changes on-the-fly", () => {
|
|
1241
1200
|
scope.min = "08:45:00";
|
|
1242
|
-
|
|
1201
|
+
inputElm = $compile(
|
|
1243
1202
|
'<input type="time" ng-model="value" name="alias" min="{{min}}" />',
|
|
1244
1203
|
)(scope);
|
|
1245
1204
|
|
|
@@ -1255,7 +1214,7 @@ describe("input", () => {
|
|
|
1255
1214
|
|
|
1256
1215
|
it("should validate even if ng-max value changes on-the-fly", () => {
|
|
1257
1216
|
scope.max = "04:02:00";
|
|
1258
|
-
|
|
1217
|
+
inputElm = $compile(
|
|
1259
1218
|
'<input type="time" ng-model="value" name="alias" ng-max="max" />',
|
|
1260
1219
|
)(scope);
|
|
1261
1220
|
|
|
@@ -1271,7 +1230,7 @@ describe("input", () => {
|
|
|
1271
1230
|
|
|
1272
1231
|
it("should validate even if ng-min value changes on-the-fly", () => {
|
|
1273
1232
|
scope.min = "08:45:00";
|
|
1274
|
-
|
|
1233
|
+
inputElm = $compile(
|
|
1275
1234
|
'<input type="time" ng-model="value" name="alias" ng-min="min" />',
|
|
1276
1235
|
)(scope);
|
|
1277
1236
|
|
|
@@ -1288,9 +1247,7 @@ describe("input", () => {
|
|
|
1288
1247
|
|
|
1289
1248
|
describe("date", () => {
|
|
1290
1249
|
it("should throw if model is a Date object.", () => {
|
|
1291
|
-
|
|
1292
|
-
scope,
|
|
1293
|
-
);
|
|
1250
|
+
inputElm = $compile('<input type="date" ng-model="birthday"/>')(scope);
|
|
1294
1251
|
|
|
1295
1252
|
expect(() => {
|
|
1296
1253
|
scope.$apply(() => {
|
|
@@ -1300,7 +1257,7 @@ describe("input", () => {
|
|
|
1300
1257
|
});
|
|
1301
1258
|
|
|
1302
1259
|
it("should set the view when the model is an valid String", () => {
|
|
1303
|
-
|
|
1260
|
+
inputElm = $compile('<input type="date" ng-model="val"/>')(scope);
|
|
1304
1261
|
|
|
1305
1262
|
scope.$apply(() => {
|
|
1306
1263
|
scope.val = "1977-10-22";
|
|
@@ -1310,7 +1267,7 @@ describe("input", () => {
|
|
|
1310
1267
|
});
|
|
1311
1268
|
|
|
1312
1269
|
it("should bind to scope when the model is an valid String", () => {
|
|
1313
|
-
|
|
1270
|
+
inputElm = $compile('<input type="date" ng-model="val"/>')(scope);
|
|
1314
1271
|
|
|
1315
1272
|
inputElm[0].value = "1977-10-22";
|
|
1316
1273
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -1319,9 +1276,7 @@ describe("input", () => {
|
|
|
1319
1276
|
});
|
|
1320
1277
|
|
|
1321
1278
|
it("should set the model to null if the view is invalid", () => {
|
|
1322
|
-
|
|
1323
|
-
scope,
|
|
1324
|
-
);
|
|
1279
|
+
inputElm = $compile('<input type="date" ng-model="arrMatey"/>')(scope);
|
|
1325
1280
|
|
|
1326
1281
|
scope.$apply(() => {
|
|
1327
1282
|
scope.arrMatey = "2014-09-14";
|
|
@@ -1337,9 +1292,7 @@ describe("input", () => {
|
|
|
1337
1292
|
});
|
|
1338
1293
|
|
|
1339
1294
|
it("should render as blank if null", () => {
|
|
1340
|
-
|
|
1341
|
-
scope,
|
|
1342
|
-
);
|
|
1295
|
+
inputElm = $compile('<input type="date" ng-model="test" />')(scope);
|
|
1343
1296
|
|
|
1344
1297
|
scope.$apply("test = null");
|
|
1345
1298
|
|
|
@@ -1348,9 +1301,7 @@ describe("input", () => {
|
|
|
1348
1301
|
});
|
|
1349
1302
|
|
|
1350
1303
|
it("should come up blank when no value specified", () => {
|
|
1351
|
-
|
|
1352
|
-
scope,
|
|
1353
|
-
);
|
|
1304
|
+
inputElm = $compile('<input type="date" ng-model="test" />')(scope);
|
|
1354
1305
|
|
|
1355
1306
|
expect(inputElm.val()).toBe("");
|
|
1356
1307
|
|
|
@@ -1361,9 +1312,7 @@ describe("input", () => {
|
|
|
1361
1312
|
});
|
|
1362
1313
|
|
|
1363
1314
|
it("should parse empty string to null", () => {
|
|
1364
|
-
|
|
1365
|
-
scope,
|
|
1366
|
-
);
|
|
1315
|
+
inputElm = $compile('<input type="date" ng-model="test" />')(scope);
|
|
1367
1316
|
|
|
1368
1317
|
scope.$apply(() => {
|
|
1369
1318
|
scope.test = "2014-09-14";
|
|
@@ -1379,7 +1328,7 @@ describe("input", () => {
|
|
|
1379
1328
|
const formElm = $compile(
|
|
1380
1329
|
'<form name="form"><input type="date" ng-model="value" name="alias" min="2000-01-01" /></form>',
|
|
1381
1330
|
)(scope);
|
|
1382
|
-
|
|
1331
|
+
inputElm = formElm.find("input");
|
|
1383
1332
|
inputElm[0].value = "1999-12-31";
|
|
1384
1333
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
1385
1334
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
@@ -1391,7 +1340,7 @@ describe("input", () => {
|
|
|
1391
1340
|
const formElm = $compile(
|
|
1392
1341
|
'<form name="form"><input type="date" ng-model="value" name="alias" min="2000-01-01" /></form>',
|
|
1393
1342
|
)(scope);
|
|
1394
|
-
|
|
1343
|
+
inputElm = formElm.find("input");
|
|
1395
1344
|
inputElm[0].value = "2000-01-01";
|
|
1396
1345
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
1397
1346
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -1403,7 +1352,7 @@ describe("input", () => {
|
|
|
1403
1352
|
const formElm = $compile(
|
|
1404
1353
|
'<form name="form"><input name="alias" ng-model="value" type="date" min >',
|
|
1405
1354
|
)(scope);
|
|
1406
|
-
|
|
1355
|
+
inputElm = formElm.find("input");
|
|
1407
1356
|
|
|
1408
1357
|
scope.value = "2000-01-01";
|
|
1409
1358
|
scope.$digest();
|
|
@@ -1417,7 +1366,7 @@ describe("input", () => {
|
|
|
1417
1366
|
const formElm = $compile(
|
|
1418
1367
|
'<form name="form"><input type="date" ng-model="value" name="alias" max="2019-01-01" /></form>',
|
|
1419
1368
|
)(scope);
|
|
1420
|
-
|
|
1369
|
+
inputElm = formElm.find("input");
|
|
1421
1370
|
|
|
1422
1371
|
inputElm[0].value = "2019-12-31";
|
|
1423
1372
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -1430,7 +1379,7 @@ describe("input", () => {
|
|
|
1430
1379
|
const formElm = $compile(
|
|
1431
1380
|
'<form name="form"><input type="date" ng-model="value" name="alias" max="2019-01-01" /></form>',
|
|
1432
1381
|
)(scope);
|
|
1433
|
-
|
|
1382
|
+
inputElm = formElm.find("input");
|
|
1434
1383
|
|
|
1435
1384
|
inputElm[0].value = "2000-01-01";
|
|
1436
1385
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -1465,7 +1414,7 @@ describe("input", () => {
|
|
|
1465
1414
|
|
|
1466
1415
|
it("should validate even if max value changes on-the-fly", () => {
|
|
1467
1416
|
scope.max = "2013-01-01";
|
|
1468
|
-
|
|
1417
|
+
inputElm = $compile(
|
|
1469
1418
|
'<input type="date" ng-model="value" name="alias" max="{{max}}" />',
|
|
1470
1419
|
)(scope);
|
|
1471
1420
|
|
|
@@ -1486,7 +1435,7 @@ describe("input", () => {
|
|
|
1486
1435
|
|
|
1487
1436
|
it("should validate even if min value changes on-the-fly", () => {
|
|
1488
1437
|
scope.min = "2013-01-01";
|
|
1489
|
-
|
|
1438
|
+
inputElm = $compile(
|
|
1490
1439
|
'<input type="date" ng-model="value" name="alias" min="{{min}}" />',
|
|
1491
1440
|
)(scope);
|
|
1492
1441
|
|
|
@@ -1507,7 +1456,7 @@ describe("input", () => {
|
|
|
1507
1456
|
|
|
1508
1457
|
it("should validate even if ng-max value changes on-the-fly", () => {
|
|
1509
1458
|
scope.max = "2013-01-01";
|
|
1510
|
-
|
|
1459
|
+
inputElm = $compile(
|
|
1511
1460
|
'<input type="date" ng-model="value" name="alias" ng-max="max" />',
|
|
1512
1461
|
)(scope);
|
|
1513
1462
|
|
|
@@ -1528,7 +1477,7 @@ describe("input", () => {
|
|
|
1528
1477
|
|
|
1529
1478
|
it("should validate even if ng-min value changes on-the-fly", () => {
|
|
1530
1479
|
scope.min = "2013-01-01";
|
|
1531
|
-
|
|
1480
|
+
inputElm = $compile(
|
|
1532
1481
|
'<input type="date" ng-model="value" name="alias" ng-min="min" />',
|
|
1533
1482
|
)(scope);
|
|
1534
1483
|
|
|
@@ -1549,7 +1498,7 @@ describe("input", () => {
|
|
|
1549
1498
|
|
|
1550
1499
|
it("should allow Date objects as valid ng-max values", () => {
|
|
1551
1500
|
scope.max = new Date(2012, 1, 1, 1, 2, 0);
|
|
1552
|
-
|
|
1501
|
+
inputElm = $compile(
|
|
1553
1502
|
'<input type="date" ng-model="value" name="alias" ng-max="max" />',
|
|
1554
1503
|
)(scope);
|
|
1555
1504
|
|
|
@@ -1570,7 +1519,7 @@ describe("input", () => {
|
|
|
1570
1519
|
|
|
1571
1520
|
it("should allow Date objects as valid ng-min values", () => {
|
|
1572
1521
|
scope.min = new Date(2013, 1, 1, 1, 2, 0);
|
|
1573
|
-
|
|
1522
|
+
inputElm = $compile(
|
|
1574
1523
|
'<input type="date" ng-model="value" name="alias" ng-min="min" />',
|
|
1575
1524
|
)(scope);
|
|
1576
1525
|
|
|
@@ -1712,9 +1661,7 @@ describe("input", () => {
|
|
|
1712
1661
|
};
|
|
1713
1662
|
|
|
1714
1663
|
it("should reset the model if view is invalid", () => {
|
|
1715
|
-
|
|
1716
|
-
scope,
|
|
1717
|
-
);
|
|
1664
|
+
inputElm = $compile('<input type="number" ng-model="age"/>')(scope);
|
|
1718
1665
|
|
|
1719
1666
|
scope.$apply("age = 123");
|
|
1720
1667
|
expect(inputElm.val()).toBe("123");
|
|
@@ -1728,9 +1675,7 @@ describe("input", () => {
|
|
|
1728
1675
|
});
|
|
1729
1676
|
|
|
1730
1677
|
it("should render as blank if null", () => {
|
|
1731
|
-
|
|
1732
|
-
scope,
|
|
1733
|
-
);
|
|
1678
|
+
inputElm = $compile('<input type="number" ng-model="age" />')(scope);
|
|
1734
1679
|
|
|
1735
1680
|
scope.$apply("age = null");
|
|
1736
1681
|
|
|
@@ -1739,9 +1684,7 @@ describe("input", () => {
|
|
|
1739
1684
|
});
|
|
1740
1685
|
|
|
1741
1686
|
it("should come up blank when no value specified", () => {
|
|
1742
|
-
|
|
1743
|
-
scope,
|
|
1744
|
-
);
|
|
1687
|
+
inputElm = $compile('<input type="number" ng-model="age" />')(scope);
|
|
1745
1688
|
|
|
1746
1689
|
expect(inputElm.val()).toBe("");
|
|
1747
1690
|
|
|
@@ -1752,9 +1695,7 @@ describe("input", () => {
|
|
|
1752
1695
|
});
|
|
1753
1696
|
|
|
1754
1697
|
it("should parse empty string to null", () => {
|
|
1755
|
-
|
|
1756
|
-
scope,
|
|
1757
|
-
);
|
|
1698
|
+
inputElm = $compile('<input type="number" ng-model="age" />')(scope);
|
|
1758
1699
|
|
|
1759
1700
|
scope.$apply("age = 10");
|
|
1760
1701
|
|
|
@@ -1766,9 +1707,7 @@ describe("input", () => {
|
|
|
1766
1707
|
});
|
|
1767
1708
|
|
|
1768
1709
|
it("should only invalidate the model if suffering from bad input when the data is parsed", () => {
|
|
1769
|
-
|
|
1770
|
-
scope,
|
|
1771
|
-
);
|
|
1710
|
+
inputElm = $compile('<input type="number" ng-model="age" />')(scope);
|
|
1772
1711
|
|
|
1773
1712
|
expect(scope.age).toBeUndefined();
|
|
1774
1713
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -1781,9 +1720,7 @@ describe("input", () => {
|
|
|
1781
1720
|
});
|
|
1782
1721
|
|
|
1783
1722
|
it("should validate number if transition from bad input to empty string", () => {
|
|
1784
|
-
|
|
1785
|
-
scope,
|
|
1786
|
-
);
|
|
1723
|
+
inputElm = $compile('<input type="number" ng-model="age" />')(scope);
|
|
1787
1724
|
inputElm[0].value = "10a";
|
|
1788
1725
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
1789
1726
|
|
|
@@ -1794,7 +1731,7 @@ describe("input", () => {
|
|
|
1794
1731
|
});
|
|
1795
1732
|
|
|
1796
1733
|
it("should validate with undefined viewValue when $validate() called", () => {
|
|
1797
|
-
|
|
1734
|
+
inputElm = $compile(
|
|
1798
1735
|
'<form name="form"><input type="number" name="alias" ng-model="value" /></form>',
|
|
1799
1736
|
)(scope);
|
|
1800
1737
|
|
|
@@ -1816,7 +1753,7 @@ describe("input", () => {
|
|
|
1816
1753
|
const formElm = $compile(
|
|
1817
1754
|
'<form name="form"><input type="number" name="alias" ng-model="value" /></form>',
|
|
1818
1755
|
)(scope);
|
|
1819
|
-
|
|
1756
|
+
inputElm = formElm.find("input");
|
|
1820
1757
|
|
|
1821
1758
|
// #.###e+##
|
|
1822
1759
|
scope.form.alias.$setViewValue("1.23214124123412412e+26");
|
|
@@ -1880,9 +1817,7 @@ describe("input", () => {
|
|
|
1880
1817
|
});
|
|
1881
1818
|
|
|
1882
1819
|
it("should bind to scope if input is valid", () => {
|
|
1883
|
-
|
|
1884
|
-
scope,
|
|
1885
|
-
);
|
|
1820
|
+
inputElm = $compile('<input type="number" ng-model="age"/>')(scope);
|
|
1886
1821
|
const ctrl = inputElm.controller("ngModel");
|
|
1887
1822
|
|
|
1888
1823
|
let previousParserFail = false;
|
|
@@ -1916,7 +1851,7 @@ describe("input", () => {
|
|
|
1916
1851
|
const formElm = $compile(
|
|
1917
1852
|
'<form name="form"><input type="number" ng-model="value" name="alias" min="10" /></form>',
|
|
1918
1853
|
)(scope);
|
|
1919
|
-
|
|
1854
|
+
inputElm = formElm.find("input");
|
|
1920
1855
|
|
|
1921
1856
|
inputElm[0].value = "1";
|
|
1922
1857
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -1936,7 +1871,7 @@ describe("input", () => {
|
|
|
1936
1871
|
const formElm = $compile(
|
|
1937
1872
|
'<form name="form"><input type="number" ng-model-options="{allowInvalid: true}" ng-model="value" name="alias" min="10" /></form>',
|
|
1938
1873
|
)(scope);
|
|
1939
|
-
|
|
1874
|
+
inputElm = formElm.find("input");
|
|
1940
1875
|
const ngModelCtrl = inputElm.controller("ngModel");
|
|
1941
1876
|
ngModelCtrl.$parsers.push(subtract);
|
|
1942
1877
|
|
|
@@ -1958,7 +1893,7 @@ describe("input", () => {
|
|
|
1958
1893
|
|
|
1959
1894
|
it("should validate even if min value changes on-the-fly", () => {
|
|
1960
1895
|
scope.min = undefined;
|
|
1961
|
-
|
|
1896
|
+
inputElm = $compile(
|
|
1962
1897
|
'<input type="number" ng-model="value" name="alias" min="{{min}}" />',
|
|
1963
1898
|
)(scope);
|
|
1964
1899
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -1994,7 +1929,7 @@ describe("input", () => {
|
|
|
1994
1929
|
const formElm = $compile(
|
|
1995
1930
|
'<form name="form"><input type="number" ng-model="value" name="alias" ng-min="50" /></form>',
|
|
1996
1931
|
)(scope);
|
|
1997
|
-
|
|
1932
|
+
inputElm = formElm.find("input");
|
|
1998
1933
|
|
|
1999
1934
|
inputElm[0].value = "1";
|
|
2000
1935
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2013,7 +1948,7 @@ describe("input", () => {
|
|
|
2013
1948
|
const formElm = $compile(
|
|
2014
1949
|
'<form name="form"><input type="number" ng-model="value" name="alias" ng-min="10" /></form>',
|
|
2015
1950
|
)(scope);
|
|
2016
|
-
|
|
1951
|
+
inputElm = formElm.find("input");
|
|
2017
1952
|
const ngModelCtrl = inputElm.controller("ngModel");
|
|
2018
1953
|
ngModelCtrl.$parsers.push(subtract);
|
|
2019
1954
|
|
|
@@ -2035,7 +1970,7 @@ describe("input", () => {
|
|
|
2035
1970
|
|
|
2036
1971
|
it("should validate even if the ngMin value changes on-the-fly", () => {
|
|
2037
1972
|
scope.min = undefined;
|
|
2038
|
-
|
|
1973
|
+
inputElm = $compile(
|
|
2039
1974
|
'<input type="number" ng-model="value" name="alias" ng-min="min" />',
|
|
2040
1975
|
)(scope);
|
|
2041
1976
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -2071,7 +2006,7 @@ describe("input", () => {
|
|
|
2071
2006
|
const formElm = $compile(
|
|
2072
2007
|
'<form name="form"><input type="number" ng-model="value" name="alias" max="10" /></form>',
|
|
2073
2008
|
)(scope);
|
|
2074
|
-
|
|
2009
|
+
inputElm = formElm.find("input");
|
|
2075
2010
|
|
|
2076
2011
|
inputElm[0].value = "20";
|
|
2077
2012
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2091,7 +2026,7 @@ describe("input", () => {
|
|
|
2091
2026
|
'<form name="form"><input type="number"' +
|
|
2092
2027
|
'ng-model-options="{allowInvalid: true}" ng-model="value" name="alias" max="10" /></form>',
|
|
2093
2028
|
)(scope);
|
|
2094
|
-
|
|
2029
|
+
inputElm = formElm.find("input");
|
|
2095
2030
|
const ngModelCtrl = inputElm.controller("ngModel");
|
|
2096
2031
|
ngModelCtrl.$parsers.push(add);
|
|
2097
2032
|
|
|
@@ -2113,7 +2048,7 @@ describe("input", () => {
|
|
|
2113
2048
|
|
|
2114
2049
|
it("should validate even if max value changes on-the-fly", () => {
|
|
2115
2050
|
scope.max = undefined;
|
|
2116
|
-
|
|
2051
|
+
inputElm = $compile(
|
|
2117
2052
|
'<input type="number" ng-model="value" name="alias" max="{{max}}" />',
|
|
2118
2053
|
)(scope);
|
|
2119
2054
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -2149,7 +2084,7 @@ describe("input", () => {
|
|
|
2149
2084
|
const formElm = $compile(
|
|
2150
2085
|
'<form name="form"><input type="number" ng-model="value" name="alias" ng-max="5" /></form>',
|
|
2151
2086
|
)(scope);
|
|
2152
|
-
|
|
2087
|
+
inputElm = formElm.find("input");
|
|
2153
2088
|
|
|
2154
2089
|
inputElm[0].value = "20";
|
|
2155
2090
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2169,7 +2104,7 @@ describe("input", () => {
|
|
|
2169
2104
|
'<form name="form"><input type="number"' +
|
|
2170
2105
|
'ng-model-options="{allowInvalid: true}" ng-model="value" name="alias" ng-max="10" /></form>',
|
|
2171
2106
|
)(scope);
|
|
2172
|
-
|
|
2107
|
+
inputElm = formElm.find("input");
|
|
2173
2108
|
const ngModelCtrl = inputElm.controller("ngModel");
|
|
2174
2109
|
ngModelCtrl.$parsers.push(add);
|
|
2175
2110
|
|
|
@@ -2191,7 +2126,7 @@ describe("input", () => {
|
|
|
2191
2126
|
|
|
2192
2127
|
it("should validate even if the ngMax value changes on-the-fly", () => {
|
|
2193
2128
|
scope.max = undefined;
|
|
2194
|
-
|
|
2129
|
+
inputElm = $compile(
|
|
2195
2130
|
'<input type="number" ng-model="value" name="alias" ng-max="max" />',
|
|
2196
2131
|
)(scope);
|
|
2197
2132
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -2235,7 +2170,7 @@ describe("input", () => {
|
|
|
2235
2170
|
const formElm = $compile(
|
|
2236
2171
|
`<form name="form"><input type="number" ng-model="value" name="alias" ${attrHtml} /></form>`,
|
|
2237
2172
|
)(scope);
|
|
2238
|
-
|
|
2173
|
+
inputElm = formElm.find("input");
|
|
2239
2174
|
scope.$digest();
|
|
2240
2175
|
expect(inputElm.val()).toBe("20");
|
|
2241
2176
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -2268,7 +2203,7 @@ describe("input", () => {
|
|
|
2268
2203
|
const formElm = $compile(
|
|
2269
2204
|
`<form name="form"><input type="number" ng-model="value" name="alias" ${attrHtml} /></form>`,
|
|
2270
2205
|
)(scope);
|
|
2271
|
-
|
|
2206
|
+
inputElm = formElm.find("input");
|
|
2272
2207
|
inputElm[0].value = "10";
|
|
2273
2208
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
2274
2209
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -2314,7 +2249,7 @@ describe("input", () => {
|
|
|
2314
2249
|
scope.min = 5;
|
|
2315
2250
|
scope.step = 10;
|
|
2316
2251
|
scope.value = 10;
|
|
2317
|
-
|
|
2252
|
+
inputElm = $compile(
|
|
2318
2253
|
`<input type="number" ng-model="value" min="{{min}}" ${attrHtml} />`,
|
|
2319
2254
|
)(scope);
|
|
2320
2255
|
const ngModel = inputElm.controller("ngModel");
|
|
@@ -2370,7 +2305,7 @@ describe("input", () => {
|
|
|
2370
2305
|
|
|
2371
2306
|
it("should correctly validate even in cases where the JS floating point arithmetic fails", () => {
|
|
2372
2307
|
scope.step = 0.1;
|
|
2373
|
-
|
|
2308
|
+
inputElm = $compile(
|
|
2374
2309
|
`<input type="number" ng-model="value" ${attrHtml} />`,
|
|
2375
2310
|
)(scope);
|
|
2376
2311
|
const ngModel = inputElm.controller("ngModel");
|
|
@@ -2419,7 +2354,7 @@ describe("input", () => {
|
|
|
2419
2354
|
const formElm = $compile(
|
|
2420
2355
|
'<form name="form"><input type="number" ng-model="value" name="alias" required /></form>',
|
|
2421
2356
|
)(scope);
|
|
2422
|
-
|
|
2357
|
+
inputElm = formElm.find("input");
|
|
2423
2358
|
|
|
2424
2359
|
inputElm[0].value = "0";
|
|
2425
2360
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2432,7 +2367,7 @@ describe("input", () => {
|
|
|
2432
2367
|
const formElm = $compile(
|
|
2433
2368
|
'<form name="form"><input type="number" ng-model="value" name="alias" required /></form>',
|
|
2434
2369
|
)(scope);
|
|
2435
|
-
|
|
2370
|
+
inputElm = formElm.find("input");
|
|
2436
2371
|
scope.$apply("value = 0");
|
|
2437
2372
|
|
|
2438
2373
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -2444,7 +2379,7 @@ describe("input", () => {
|
|
|
2444
2379
|
const formElm = $compile(
|
|
2445
2380
|
'<form name="form"><div ng-model="value" name="alias" required></form>',
|
|
2446
2381
|
)(scope);
|
|
2447
|
-
|
|
2382
|
+
inputElm = formElm.find("div");
|
|
2448
2383
|
|
|
2449
2384
|
scope.$apply("value = ''");
|
|
2450
2385
|
|
|
@@ -2453,7 +2388,7 @@ describe("input", () => {
|
|
|
2453
2388
|
});
|
|
2454
2389
|
|
|
2455
2390
|
it("should not invalidate number if ng-required=false and viewValue has not been committed", () => {
|
|
2456
|
-
|
|
2391
|
+
inputElm = $compile(
|
|
2457
2392
|
'<input type="number" ng-model="value" name="alias" ng-required="required">',
|
|
2458
2393
|
)(scope);
|
|
2459
2394
|
|
|
@@ -2469,7 +2404,7 @@ describe("input", () => {
|
|
|
2469
2404
|
const formElm = $compile(
|
|
2470
2405
|
'<form name="form"><input type="number" ng-model="value" name="numberInput" ng-required="true" /></form>',
|
|
2471
2406
|
)(scope);
|
|
2472
|
-
|
|
2407
|
+
inputElm = formElm.find("input");
|
|
2473
2408
|
|
|
2474
2409
|
inputElm[0].value = "0";
|
|
2475
2410
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2482,7 +2417,7 @@ describe("input", () => {
|
|
|
2482
2417
|
const formElm = $compile(
|
|
2483
2418
|
'<form name="form"><input type="number" ng-model="value" name="numberInput" ng-required="true" /></form>',
|
|
2484
2419
|
)(scope);
|
|
2485
|
-
|
|
2420
|
+
inputElm = formElm.find("input");
|
|
2486
2421
|
|
|
2487
2422
|
scope.$apply("value = 0");
|
|
2488
2423
|
|
|
@@ -2495,7 +2430,7 @@ describe("input", () => {
|
|
|
2495
2430
|
const formElm = $compile(
|
|
2496
2431
|
'<form name="form"><div ng-model="value" name="numberInput" ng-required="true"></form>',
|
|
2497
2432
|
)(scope);
|
|
2498
|
-
|
|
2433
|
+
inputElm = formElm.find("div");
|
|
2499
2434
|
|
|
2500
2435
|
scope.$apply("value = ''");
|
|
2501
2436
|
|
|
@@ -2507,7 +2442,7 @@ describe("input", () => {
|
|
|
2507
2442
|
const formElm = $compile(
|
|
2508
2443
|
'<form name="form"><input type="number" ng-model="value" name="numberInput" ng-required="ngRequiredExpr" /></form>',
|
|
2509
2444
|
)(scope);
|
|
2510
|
-
|
|
2445
|
+
inputElm = formElm.find("input");
|
|
2511
2446
|
|
|
2512
2447
|
scope.$apply("ngRequiredExpr = true");
|
|
2513
2448
|
|
|
@@ -2528,7 +2463,7 @@ describe("input", () => {
|
|
|
2528
2463
|
const formElm = $compile(
|
|
2529
2464
|
'<form name="form"><input type="number" ng-model="value" name="numberInput" ng-required="false" /></form>',
|
|
2530
2465
|
)(scope);
|
|
2531
|
-
|
|
2466
|
+
inputElm = formElm.find("input");
|
|
2532
2467
|
|
|
2533
2468
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2534
2469
|
expect(scope.value).toBeUndefined();
|
|
@@ -2540,7 +2475,7 @@ describe("input", () => {
|
|
|
2540
2475
|
const formElm = $compile(
|
|
2541
2476
|
'<form name="form"><input type="number" ng-model="value" name="numberInput" ng-required="false" /></form>',
|
|
2542
2477
|
)(scope);
|
|
2543
|
-
|
|
2478
|
+
inputElm = formElm.find("input");
|
|
2544
2479
|
|
|
2545
2480
|
inputElm[0].value = "42";
|
|
2546
2481
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2553,7 +2488,7 @@ describe("input", () => {
|
|
|
2553
2488
|
const formElm = $compile(
|
|
2554
2489
|
'<form name="form"><div ng-model="value" name="numberInput" ng-required="false"><form>',
|
|
2555
2490
|
)(scope);
|
|
2556
|
-
|
|
2491
|
+
inputElm = formElm.find("div");
|
|
2557
2492
|
|
|
2558
2493
|
scope.$apply("value = ''");
|
|
2559
2494
|
|
|
@@ -2565,7 +2500,7 @@ describe("input", () => {
|
|
|
2565
2500
|
const formElm = $compile(
|
|
2566
2501
|
'<form name="form"><input type="number" ng-model="value" name="numberInput" ng-required="ngRequiredExpr" /><form>',
|
|
2567
2502
|
)(scope);
|
|
2568
|
-
|
|
2503
|
+
inputElm = formElm.find("input");
|
|
2569
2504
|
|
|
2570
2505
|
scope.$apply("ngRequiredExpr = false");
|
|
2571
2506
|
|
|
@@ -2584,7 +2519,7 @@ describe("input", () => {
|
|
|
2584
2519
|
|
|
2585
2520
|
describe("minlength", () => {
|
|
2586
2521
|
it("should invalidate values that are shorter than the given minlength", () => {
|
|
2587
|
-
|
|
2522
|
+
inputElm = $compile(
|
|
2588
2523
|
'<input type="number" ng-model="value" ng-minlength="3" />',
|
|
2589
2524
|
)(scope);
|
|
2590
2525
|
|
|
@@ -2601,7 +2536,7 @@ describe("input", () => {
|
|
|
2601
2536
|
const formElm = $compile(
|
|
2602
2537
|
'<form name="form"><input type="number" name="input" ng-model="value" minlength="{{ min }}" /></form>',
|
|
2603
2538
|
)(scope);
|
|
2604
|
-
|
|
2539
|
+
inputElm = formElm.find("input");
|
|
2605
2540
|
scope.$apply(() => {
|
|
2606
2541
|
scope.min = 10;
|
|
2607
2542
|
});
|
|
@@ -2622,7 +2557,7 @@ describe("input", () => {
|
|
|
2622
2557
|
|
|
2623
2558
|
describe("maxlength", () => {
|
|
2624
2559
|
it("should invalidate values that are longer than the given maxlength", () => {
|
|
2625
|
-
|
|
2560
|
+
inputElm = $compile(
|
|
2626
2561
|
'<input type="number" ng-model="value" ng-maxlength="5" />',
|
|
2627
2562
|
)(scope);
|
|
2628
2563
|
|
|
@@ -2639,7 +2574,7 @@ describe("input", () => {
|
|
|
2639
2574
|
const formElm = $compile(
|
|
2640
2575
|
'<form name="form"><input type="number" name="input" ng-model="value" maxlength="{{ max }}" /></form>',
|
|
2641
2576
|
)(scope);
|
|
2642
|
-
|
|
2577
|
+
inputElm = formElm.find("input");
|
|
2643
2578
|
scope.$apply(() => {
|
|
2644
2579
|
scope.max = 1;
|
|
2645
2580
|
});
|
|
@@ -2664,9 +2599,7 @@ describe("input", () => {
|
|
|
2664
2599
|
const supportsRange = rangeTestEl[0].type === "range";
|
|
2665
2600
|
|
|
2666
2601
|
it("should render as 50 if null", () => {
|
|
2667
|
-
|
|
2668
|
-
scope,
|
|
2669
|
-
);
|
|
2602
|
+
inputElm = $compile('<input type="range" ng-model="age" />')(scope);
|
|
2670
2603
|
|
|
2671
2604
|
inputElm[0].value = "25";
|
|
2672
2605
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2678,9 +2611,7 @@ describe("input", () => {
|
|
|
2678
2611
|
});
|
|
2679
2612
|
|
|
2680
2613
|
it("should set model to 50 when no value specified and default min/max", () => {
|
|
2681
|
-
|
|
2682
|
-
scope,
|
|
2683
|
-
);
|
|
2614
|
+
inputElm = $compile('<input type="range" ng-model="age" />')(scope);
|
|
2684
2615
|
|
|
2685
2616
|
expect(inputElm.val()).toBe("50");
|
|
2686
2617
|
|
|
@@ -2690,9 +2621,7 @@ describe("input", () => {
|
|
|
2690
2621
|
});
|
|
2691
2622
|
|
|
2692
2623
|
it("should parse non-number values to 50 when default min/max", () => {
|
|
2693
|
-
|
|
2694
|
-
scope,
|
|
2695
|
-
);
|
|
2624
|
+
inputElm = $compile('<input type="range" ng-model="age" />')(scope);
|
|
2696
2625
|
|
|
2697
2626
|
scope.$apply("age = 10");
|
|
2698
2627
|
expect(inputElm.val()).toBe("10");
|
|
@@ -2704,9 +2633,7 @@ describe("input", () => {
|
|
|
2704
2633
|
});
|
|
2705
2634
|
|
|
2706
2635
|
it("should parse the input value to a Number", () => {
|
|
2707
|
-
|
|
2708
|
-
scope,
|
|
2709
|
-
);
|
|
2636
|
+
inputElm = $compile('<input type="range" ng-model="age" />')(scope);
|
|
2710
2637
|
|
|
2711
2638
|
inputElm[0].value = "75";
|
|
2712
2639
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2716,9 +2643,7 @@ describe("input", () => {
|
|
|
2716
2643
|
it("should only invalidate the model if suffering from bad input when the data is parsed", () => {
|
|
2717
2644
|
scope.age = 60;
|
|
2718
2645
|
|
|
2719
|
-
|
|
2720
|
-
scope,
|
|
2721
|
-
);
|
|
2646
|
+
inputElm = $compile('<input type="range" ng-model="age" />')(scope);
|
|
2722
2647
|
|
|
2723
2648
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2724
2649
|
|
|
@@ -2732,9 +2657,7 @@ describe("input", () => {
|
|
|
2732
2657
|
it("should throw if the model value is not a number", () => {
|
|
2733
2658
|
expect(() => {
|
|
2734
2659
|
scope.value = "one";
|
|
2735
|
-
|
|
2736
|
-
scope,
|
|
2737
|
-
);
|
|
2660
|
+
inputElm = $compile('<input type="range" ng-model="value" />')(scope);
|
|
2738
2661
|
scope.$digest();
|
|
2739
2662
|
}).toThrowError(/numfmt/);
|
|
2740
2663
|
});
|
|
@@ -2746,7 +2669,7 @@ describe("input", () => {
|
|
|
2746
2669
|
const formElm = $compile(
|
|
2747
2670
|
'<form name="form"><input type="range" ng-model="value" name="alias" min="{{min}}" /></form>',
|
|
2748
2671
|
)(scope);
|
|
2749
|
-
|
|
2672
|
+
inputElm = formElm.find("input");
|
|
2750
2673
|
scope.$digest();
|
|
2751
2674
|
|
|
2752
2675
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
@@ -2760,7 +2683,7 @@ describe("input", () => {
|
|
|
2760
2683
|
const formElm = $compile(
|
|
2761
2684
|
'<form name="form"><input type="range" ng-model="value" name="alias" min="10" /></form>',
|
|
2762
2685
|
)(scope);
|
|
2763
|
-
|
|
2686
|
+
inputElm = formElm.find("input");
|
|
2764
2687
|
|
|
2765
2688
|
inputElm[0].value = "5";
|
|
2766
2689
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2778,7 +2701,7 @@ describe("input", () => {
|
|
|
2778
2701
|
it("should set the model to the min val if it is less than the min val", () => {
|
|
2779
2702
|
scope.value = -10;
|
|
2780
2703
|
// Default min is 0
|
|
2781
|
-
|
|
2704
|
+
inputElm = $compile(
|
|
2782
2705
|
'<input type="range" ng-model="value" name="alias" min="{{min}}" />',
|
|
2783
2706
|
)(scope);
|
|
2784
2707
|
scope.$digest();
|
|
@@ -2796,7 +2719,7 @@ describe("input", () => {
|
|
|
2796
2719
|
|
|
2797
2720
|
it("should adjust the element and model value when the min value changes on-the-fly", () => {
|
|
2798
2721
|
scope.min = 10;
|
|
2799
|
-
|
|
2722
|
+
inputElm = $compile(
|
|
2800
2723
|
'<input type="range" ng-model="value" name="alias" min="{{min}}" />',
|
|
2801
2724
|
)(scope);
|
|
2802
2725
|
scope.$digest();
|
|
@@ -2839,7 +2762,7 @@ describe("input", () => {
|
|
|
2839
2762
|
const formElm = $compile(
|
|
2840
2763
|
'<form name="form"><input type="range" ng-model="value" name="alias" max="{{max}}" /></form>',
|
|
2841
2764
|
)(scope);
|
|
2842
|
-
|
|
2765
|
+
inputElm = formElm.find("input");
|
|
2843
2766
|
scope.$digest();
|
|
2844
2767
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2845
2768
|
expect(inputElm.val()).toBe("130");
|
|
@@ -2851,7 +2774,7 @@ describe("input", () => {
|
|
|
2851
2774
|
const formElm = $compile(
|
|
2852
2775
|
'<form name="form"><input type="range" ng-model="value" name="alias" max="10" /></form>',
|
|
2853
2776
|
)(scope);
|
|
2854
|
-
|
|
2777
|
+
inputElm = formElm.find("input");
|
|
2855
2778
|
|
|
2856
2779
|
inputElm[0].value = "20";
|
|
2857
2780
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2869,7 +2792,7 @@ describe("input", () => {
|
|
|
2869
2792
|
it("should set the model to the max val if it is greater than the max val", () => {
|
|
2870
2793
|
scope.value = 110;
|
|
2871
2794
|
// Default max is 100
|
|
2872
|
-
|
|
2795
|
+
inputElm = $compile(
|
|
2873
2796
|
'<input type="range" ng-model="value" name="alias" max="{{max}}" />',
|
|
2874
2797
|
)(scope);
|
|
2875
2798
|
scope.$digest();
|
|
@@ -2886,7 +2809,7 @@ describe("input", () => {
|
|
|
2886
2809
|
|
|
2887
2810
|
it("should adjust the element and model value if the max value changes on-the-fly", () => {
|
|
2888
2811
|
scope.max = 10;
|
|
2889
|
-
|
|
2812
|
+
inputElm = $compile(
|
|
2890
2813
|
'<input type="range" ng-model="value" name="alias" max="{{max}}" />',
|
|
2891
2814
|
)(scope);
|
|
2892
2815
|
scope.$digest();
|
|
@@ -2924,7 +2847,7 @@ describe("input", () => {
|
|
|
2924
2847
|
it("should set the correct initial value when min and max are specified", () => {
|
|
2925
2848
|
scope.max = 80;
|
|
2926
2849
|
scope.min = 40;
|
|
2927
|
-
|
|
2850
|
+
inputElm = $compile(
|
|
2928
2851
|
'<input type="range" ng-model="value" name="alias" max="{{max}}" min="{{min}}" />',
|
|
2929
2852
|
)(scope);
|
|
2930
2853
|
scope.$digest();
|
|
@@ -2935,7 +2858,7 @@ describe("input", () => {
|
|
|
2935
2858
|
|
|
2936
2859
|
it("should set element and model value to min if max is less than min", () => {
|
|
2937
2860
|
scope.min = 40;
|
|
2938
|
-
|
|
2861
|
+
inputElm = $compile(
|
|
2939
2862
|
'<input type="range" ng-model="value" name="alias" max="{{max}}" min="{{min}}" />',
|
|
2940
2863
|
)(scope);
|
|
2941
2864
|
scope.$digest();
|
|
@@ -2959,7 +2882,7 @@ describe("input", () => {
|
|
|
2959
2882
|
const formElm = $compile(
|
|
2960
2883
|
'<form name="form"><input type="range" ng-model="value" name="alias" step="5" /></form>',
|
|
2961
2884
|
)(scope);
|
|
2962
|
-
|
|
2885
|
+
inputElm = formElm.find("input");
|
|
2963
2886
|
|
|
2964
2887
|
inputElm[0].value = "5";
|
|
2965
2888
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -2996,7 +2919,7 @@ describe("input", () => {
|
|
|
2996
2919
|
const formElm = $compile(
|
|
2997
2920
|
'<form name="form"><input type="range" ng-model="value" name="alias" step="5" /></form>',
|
|
2998
2921
|
)(scope);
|
|
2999
|
-
|
|
2922
|
+
inputElm = formElm.find("input");
|
|
3000
2923
|
|
|
3001
2924
|
scope.$apply("value = 10");
|
|
3002
2925
|
expect(inputElm.val()).toBe("10");
|
|
@@ -3038,7 +2961,7 @@ describe("input", () => {
|
|
|
3038
2961
|
'<input type="email" ng-model="email" name="alias" />' +
|
|
3039
2962
|
"</form>",
|
|
3040
2963
|
)(scope);
|
|
3041
|
-
|
|
2964
|
+
inputElm = formElm.find("input");
|
|
3042
2965
|
|
|
3043
2966
|
const widget = scope.form.alias;
|
|
3044
2967
|
inputElm[0].value = "vojta@google.com";
|
|
@@ -3212,7 +3135,7 @@ describe("input", () => {
|
|
|
3212
3135
|
'<input type="url" ng-model="url" name="alias" />',
|
|
3213
3136
|
+"</form>",
|
|
3214
3137
|
)(scope);
|
|
3215
|
-
|
|
3138
|
+
inputElm = formElm.find("input");
|
|
3216
3139
|
|
|
3217
3140
|
const widget = scope.form.alias;
|
|
3218
3141
|
|
|
@@ -3352,7 +3275,7 @@ describe("input", () => {
|
|
|
3352
3275
|
describe("radio", () => {
|
|
3353
3276
|
["click", "change"].forEach((event) => {
|
|
3354
3277
|
it("should update the model on $prop event", () => {
|
|
3355
|
-
|
|
3278
|
+
inputElm = $compile(
|
|
3356
3279
|
'<input type="radio" ng-model="color" value="white" />' +
|
|
3357
3280
|
'<input type="radio" ng-model="color" value="red" />' +
|
|
3358
3281
|
'<input type="radio" ng-model="color" value="blue" />',
|
|
@@ -3376,7 +3299,7 @@ describe("input", () => {
|
|
|
3376
3299
|
});
|
|
3377
3300
|
|
|
3378
3301
|
it("should treat the value as a string when evaluating checked-ness", () => {
|
|
3379
|
-
|
|
3302
|
+
inputElm = $compile(
|
|
3380
3303
|
'<input type="radio" ng-model="model" value="0" />',
|
|
3381
3304
|
)(scope);
|
|
3382
3305
|
|
|
@@ -3389,7 +3312,7 @@ describe("input", () => {
|
|
|
3389
3312
|
|
|
3390
3313
|
it("should allow {{expr}} as value", () => {
|
|
3391
3314
|
scope.some = 11;
|
|
3392
|
-
|
|
3315
|
+
inputElm = $compile(
|
|
3393
3316
|
'<input type="radio" ng-model="value" value="{{some}}" />' +
|
|
3394
3317
|
'<input type="radio" ng-model="value" value="{{other}}" />',
|
|
3395
3318
|
)(scope);
|
|
@@ -3415,7 +3338,7 @@ describe("input", () => {
|
|
|
3415
3338
|
|
|
3416
3339
|
it("should allow the use of ngTrim", () => {
|
|
3417
3340
|
scope.some = 11;
|
|
3418
|
-
|
|
3341
|
+
inputElm = $compile(
|
|
3419
3342
|
'<input type="radio" ng-model="value" value="opt1" />' +
|
|
3420
3343
|
'<input type="radio" ng-model="value" value=" opt2 " />' +
|
|
3421
3344
|
'<input type="radio" ng-model="value" ng-trim="false" value=" opt3 " />' +
|
|
@@ -3467,7 +3390,7 @@ describe("input", () => {
|
|
|
3467
3390
|
|
|
3468
3391
|
describe("checkbox", () => {
|
|
3469
3392
|
it("should ignore checkbox without ngModel directive", () => {
|
|
3470
|
-
|
|
3393
|
+
inputElm = $compile(
|
|
3471
3394
|
'<input type="checkbox" name="whatever" required />',
|
|
3472
3395
|
)(scope);
|
|
3473
3396
|
|
|
@@ -3481,9 +3404,9 @@ describe("input", () => {
|
|
|
3481
3404
|
|
|
3482
3405
|
["click", "change"].forEach((event) => {
|
|
3483
3406
|
it("should update the model on $prop event", () => {
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
)
|
|
3407
|
+
inputElm = $compile('<input type="checkbox" ng-model="checkbox" />')(
|
|
3408
|
+
scope,
|
|
3409
|
+
);
|
|
3487
3410
|
|
|
3488
3411
|
expect(inputElm[0].checked).toBe(false);
|
|
3489
3412
|
|
|
@@ -3501,9 +3424,7 @@ describe("input", () => {
|
|
|
3501
3424
|
});
|
|
3502
3425
|
|
|
3503
3426
|
it("should format booleans", () => {
|
|
3504
|
-
|
|
3505
|
-
scope,
|
|
3506
|
-
);
|
|
3427
|
+
inputElm = $compile('<input type="checkbox" ng-model="name" />')(scope);
|
|
3507
3428
|
|
|
3508
3429
|
scope.$apply("name = false");
|
|
3509
3430
|
expect(inputElm[0].checked).toBe(false);
|
|
@@ -3513,9 +3434,9 @@ describe("input", () => {
|
|
|
3513
3434
|
});
|
|
3514
3435
|
|
|
3515
3436
|
it('should support type="checkbox" with non-standard capitalization', () => {
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
)
|
|
3437
|
+
inputElm = $compile('<input type="checkBox" ng-model="checkbox" />')(
|
|
3438
|
+
scope,
|
|
3439
|
+
);
|
|
3519
3440
|
|
|
3520
3441
|
inputElm[0].click();
|
|
3521
3442
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -3527,7 +3448,7 @@ describe("input", () => {
|
|
|
3527
3448
|
});
|
|
3528
3449
|
|
|
3529
3450
|
it("should allow custom enumeration", () => {
|
|
3530
|
-
|
|
3451
|
+
inputElm = $compile(
|
|
3531
3452
|
'<input type="checkbox" ng-model="name" ng-true-value="\'y\'" ' +
|
|
3532
3453
|
"ng-false-value=\"'n'\">",
|
|
3533
3454
|
)(scope);
|
|
@@ -3552,7 +3473,7 @@ describe("input", () => {
|
|
|
3552
3473
|
|
|
3553
3474
|
it("should throw if ngTrueValue is present and not a constant expression", () => {
|
|
3554
3475
|
expect(() => {
|
|
3555
|
-
|
|
3476
|
+
inputElm = $compile(
|
|
3556
3477
|
'<input type="checkbox" ng-model="value" ng-true-value="yes" />',
|
|
3557
3478
|
)(scope);
|
|
3558
3479
|
}).toThrowError(/constexpr/);
|
|
@@ -3560,7 +3481,7 @@ describe("input", () => {
|
|
|
3560
3481
|
|
|
3561
3482
|
it("should throw if ngFalseValue is present and not a constant expression", () => {
|
|
3562
3483
|
expect(() => {
|
|
3563
|
-
|
|
3484
|
+
inputElm = $compile(
|
|
3564
3485
|
'<input type="checkbox" ng-model="value" ng-false-value="no" />',
|
|
3565
3486
|
)(scope);
|
|
3566
3487
|
}).toThrowError(/constexpr/);
|
|
@@ -3568,14 +3489,14 @@ describe("input", () => {
|
|
|
3568
3489
|
|
|
3569
3490
|
it("should not throw if ngTrueValue or ngFalseValue are not present", () => {
|
|
3570
3491
|
expect(() => {
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
)
|
|
3492
|
+
inputElm = $compile('<input type="checkbox" ng-model="value" />')(
|
|
3493
|
+
scope,
|
|
3494
|
+
);
|
|
3574
3495
|
}).not.toThrow();
|
|
3575
3496
|
});
|
|
3576
3497
|
|
|
3577
3498
|
it("should be required if false", () => {
|
|
3578
|
-
|
|
3499
|
+
inputElm = $compile(
|
|
3579
3500
|
'<input type="checkbox" ng-model="value" required />',
|
|
3580
3501
|
)(scope);
|
|
3581
3502
|
|
|
@@ -3598,7 +3519,7 @@ describe("input", () => {
|
|
|
3598
3519
|
)(scope);
|
|
3599
3520
|
scope.$digest();
|
|
3600
3521
|
|
|
3601
|
-
|
|
3522
|
+
inputElm = formElm.find("input");
|
|
3602
3523
|
|
|
3603
3524
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
3604
3525
|
expect(scope.form.cb.$error.required).toBe(true);
|
|
@@ -3613,9 +3534,7 @@ describe("input", () => {
|
|
|
3613
3534
|
|
|
3614
3535
|
describe("textarea", () => {
|
|
3615
3536
|
it("should process textarea", () => {
|
|
3616
|
-
|
|
3617
|
-
scope,
|
|
3618
|
-
);
|
|
3537
|
+
inputElm = $compile('<textarea ng-model="name"></textarea>')(scope);
|
|
3619
3538
|
|
|
3620
3539
|
scope.$apply("name = 'Adam'");
|
|
3621
3540
|
expect(inputElm.val()).toEqual("Adam");
|
|
@@ -3630,9 +3549,9 @@ describe("input", () => {
|
|
|
3630
3549
|
});
|
|
3631
3550
|
|
|
3632
3551
|
it("should ignore textarea without ngModel directive", () => {
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
)
|
|
3552
|
+
inputElm = $compile('<textarea name="whatever" required></textarea>')(
|
|
3553
|
+
scope,
|
|
3554
|
+
);
|
|
3636
3555
|
|
|
3637
3556
|
inputElm[0].value = "";
|
|
3638
3557
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -3645,9 +3564,7 @@ describe("input", () => {
|
|
|
3645
3564
|
|
|
3646
3565
|
describe("ngValue", () => {
|
|
3647
3566
|
it('should update the dom "value" property and attribute', () => {
|
|
3648
|
-
|
|
3649
|
-
scope,
|
|
3650
|
-
);
|
|
3567
|
+
inputElm = $compile('<input type="submit" ng-value="value">')(scope);
|
|
3651
3568
|
|
|
3652
3569
|
scope.$apply("value = 'something'");
|
|
3653
3570
|
|
|
@@ -3656,9 +3573,7 @@ describe("input", () => {
|
|
|
3656
3573
|
});
|
|
3657
3574
|
|
|
3658
3575
|
it('should clear the "dom" value property and attribute when the value is undefined', () => {
|
|
3659
|
-
|
|
3660
|
-
scope,
|
|
3661
|
-
);
|
|
3576
|
+
inputElm = $compile('<input type="text" ng-value="value">')(scope);
|
|
3662
3577
|
|
|
3663
3578
|
scope.$apply('value = "something"');
|
|
3664
3579
|
|
|
@@ -3702,7 +3617,7 @@ describe("input", () => {
|
|
|
3702
3617
|
// );
|
|
3703
3618
|
|
|
3704
3619
|
it("should evaluate and set constant expressions", () => {
|
|
3705
|
-
|
|
3620
|
+
inputElm = $compile(
|
|
3706
3621
|
'<input type="radio" ng-model="selected" ng-value="true">' +
|
|
3707
3622
|
'<input type="radio" ng-model="selected" ng-value="false">' +
|
|
3708
3623
|
'<input type="radio" ng-model="selected" ng-value="1">',
|
|
@@ -3723,7 +3638,7 @@ describe("input", () => {
|
|
|
3723
3638
|
|
|
3724
3639
|
it("should use strict comparison between model and value", () => {
|
|
3725
3640
|
scope.selected = false;
|
|
3726
|
-
|
|
3641
|
+
inputElm = $compile(
|
|
3727
3642
|
'<input type="radio" ng-model="selected" ng-value="false">' +
|
|
3728
3643
|
'<input type="radio" ng-model="selected" ng-value="\'\'">' +
|
|
3729
3644
|
'<input type="radio" ng-model="selected" ng-value="0">',
|
|
@@ -3735,7 +3650,7 @@ describe("input", () => {
|
|
|
3735
3650
|
});
|
|
3736
3651
|
|
|
3737
3652
|
it("should watch the expression", () => {
|
|
3738
|
-
|
|
3653
|
+
inputElm = $compile(
|
|
3739
3654
|
'<input type="radio" ng-model="selected" ng-value="value">',
|
|
3740
3655
|
)(scope);
|
|
3741
3656
|
|
|
@@ -3755,7 +3670,7 @@ describe("input", () => {
|
|
|
3755
3670
|
});
|
|
3756
3671
|
|
|
3757
3672
|
it("should work inside ngRepeat", () => {
|
|
3758
|
-
|
|
3673
|
+
inputElm = $compile(
|
|
3759
3674
|
'<div><input type="radio" ng-repeat="i in items" ng-model="$parent.selected" ng-value="i.id"></div>',
|
|
3760
3675
|
)(scope);
|
|
3761
3676
|
|
|
@@ -3766,11 +3681,11 @@ describe("input", () => {
|
|
|
3766
3681
|
|
|
3767
3682
|
scope.$digest();
|
|
3768
3683
|
|
|
3769
|
-
expect(
|
|
3770
|
-
expect(
|
|
3684
|
+
expect(inputElm[0].children[0].checked).toBe(true);
|
|
3685
|
+
expect(inputElm[0].children[1].checked).toBe(false);
|
|
3771
3686
|
|
|
3772
|
-
|
|
3773
|
-
|
|
3687
|
+
inputElm[0].children[1].click();
|
|
3688
|
+
inputElm[0].children[1].dispatchEvent(new Event("change"));
|
|
3774
3689
|
|
|
3775
3690
|
expect(scope.selected).toBe(2);
|
|
3776
3691
|
});
|
|
@@ -3779,9 +3694,9 @@ describe("input", () => {
|
|
|
3779
3694
|
describe("password", () => {
|
|
3780
3695
|
// Under no circumstances should input[type=password] trim inputs
|
|
3781
3696
|
it("should not trim if ngTrim is unspecified", () => {
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
)
|
|
3697
|
+
inputElm = $compile('<input type="password" ng-model="password">')(
|
|
3698
|
+
scope,
|
|
3699
|
+
);
|
|
3785
3700
|
|
|
3786
3701
|
inputElm[0].value = " - - untrimmed - - ";
|
|
3787
3702
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
@@ -3789,7 +3704,7 @@ describe("input", () => {
|
|
|
3789
3704
|
});
|
|
3790
3705
|
|
|
3791
3706
|
it("should not trim if ngTrim !== false", () => {
|
|
3792
|
-
|
|
3707
|
+
inputElm = $compile(
|
|
3793
3708
|
'<input type="password" ng-model="password" ng-trim="true">',
|
|
3794
3709
|
)(scope);
|
|
3795
3710
|
inputElm[0].value = " - - untrimmed - - ";
|
|
@@ -3798,7 +3713,7 @@ describe("input", () => {
|
|
|
3798
3713
|
});
|
|
3799
3714
|
|
|
3800
3715
|
it("should not trim if ngTrim === false", () => {
|
|
3801
|
-
|
|
3716
|
+
inputElm = $compile(
|
|
3802
3717
|
'<input type="password" ng-model="password" ng-trim="false">',
|
|
3803
3718
|
)(scope);
|
|
3804
3719
|
inputElm[0].value = " - - untrimmed - - ";
|