@angular-wave/angular.ts 0.4.2 → 0.4.4
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/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +12 -2
- package/index.html +74 -3
- package/package.json +7 -7
- package/src/angular.spec.js +1 -269
- package/src/animations/animate-css-driver.js +2 -2
- package/src/animations/animate-css.js +12 -21
- package/src/animations/animate-js-driver.js +1 -3
- package/src/animations/animate-js.js +4 -4
- package/src/animations/animate-queue.js +23 -23
- package/src/animations/animate-runner.js +4 -8
- package/src/animations/animate.md +1 -1
- package/src/animations/animate.spec.js +0 -21
- package/src/animations/animation.js +4 -4
- package/src/animations/shared.js +14 -12
- package/src/binding.spec.js +0 -1
- package/src/core/cache/cache.js +2 -29
- package/src/core/compile/attributes.js +2 -3
- package/src/core/compile/compile.js +260 -245
- package/src/core/compile/compile.spec.js +63 -317
- package/src/core/compile/compile.test.js +1 -1
- package/src/core/controller/controller.js +2 -0
- package/src/core/di/injector.md +1 -1
- package/src/core/di/injector.spec.js +0 -2
- package/src/core/di/internal-injector.js +2 -1
- package/src/core/interpolate/interpolate.js +16 -3
- package/src/core/interpolate/interpolate.spec.js +70 -16
- package/src/core/location/location.js +0 -2
- package/src/core/location/location.spec.js +27 -27
- package/src/core/{scope/scope.html → model/model.html} +1 -1
- package/src/core/model/model.js +944 -0
- package/src/core/model/model.spec.js +3012 -0
- package/src/core/on.spec.js +0 -7
- package/src/core/parse/interpreter.js +10 -7
- package/src/core/parse/parse.js +28 -7
- package/src/core/parse/parse.spec.js +95 -91
- package/src/core/prop.spec.js +4 -60
- package/src/core/sce/sce.js +1 -2
- package/src/core/sce/sce.spec.js +0 -8
- package/src/core/scope/scope.js +62 -32
- package/src/core/scope/scope.spec.js +25 -1960
- package/src/directive/aria/aria.js +3 -6
- package/src/directive/aria/aria.spec.js +0 -87
- package/src/directive/attrs/attrs.spec.js +0 -5
- package/src/directive/{list/list.test.js → attrs/attrs.test.js} +1 -1
- package/src/{core/q/q.html → directive/attrs/boolean.html} +1 -1
- package/src/directive/attrs/boolean.spec.js +0 -15
- package/src/{core/q/q.test.js → directive/attrs/boolean.test.js} +1 -2
- package/src/{core/timeout/timeout.html → directive/attrs/element-style.html} +4 -1
- package/src/directive/attrs/element-style.spec.js +0 -8
- package/src/{core/scope/scope.test.js → directive/attrs/element-style.test.js} +1 -2
- package/src/directive/attrs/src.spec.js +0 -7
- package/src/directive/bind/bind.spec.js +0 -33
- package/src/directive/bind/bing-html.spec.js +1 -4
- package/src/{core/interval/interval.html → directive/channel/channel.html} +1 -1
- package/src/directive/channel/channel.js +29 -0
- package/src/directive/channel/channel.spec.js +52 -0
- package/src/directive/channel/channel.test.js +9 -0
- package/src/directive/class/class.js +3 -3
- package/src/directive/class/class.spec.js +9 -75
- package/src/directive/controller/controller.spec.js +0 -13
- package/src/directive/events/click.spec.js +0 -3
- package/src/directive/events/event.spec.js +0 -6
- package/src/directive/form/form.js +14 -22
- package/src/directive/form/form.spec.js +0 -65
- package/src/directive/if/if.spec.js +2 -7
- package/src/directive/if/if.test.js +1 -2
- package/src/directive/include/include.js +2 -2
- package/src/directive/include/include.spec.js +8 -59
- package/src/directive/init/init.js +6 -2
- package/src/directive/init/init.spec.js +0 -2
- package/src/directive/input/input.js +1 -2
- package/src/directive/input/input.spec.js +191 -331
- package/src/directive/messages/messages.spec.js +4 -35
- package/src/directive/model/model.js +30 -42
- package/src/directive/model/model.spec.js +2 -49
- package/src/directive/model-options/model-options.js +22 -26
- package/src/directive/model-options/model-options.spec.js +0 -6
- package/src/directive/non-bindable/non-bindable.spec.js +0 -1
- package/src/directive/observe/observe.js +0 -1
- package/src/directive/observe/observe.spec.js +0 -1
- package/src/directive/options/options.js +1 -3
- package/src/directive/options/options.spec.js +3 -38
- package/src/directive/ref/href.spec.js +0 -15
- package/src/directive/repeat/repeat.js +2 -2
- package/src/directive/repeat/repeat.spec.js +56 -192
- package/src/directive/script/script.spec.js +0 -2
- package/src/directive/select/select.js +3 -3
- package/src/directive/select/select.spec.js +9 -106
- package/src/directive/show-hide/show-hide.js +2 -2
- package/src/directive/show-hide/show-hide.spec.js +8 -19
- package/src/directive/style/style.spec.js +0 -7
- package/src/directive/switch/switch.js +1 -2
- package/src/directive/switch/switch.spec.js +5 -5
- package/src/directive/validators/validators.spec.js +0 -1
- package/src/loader.js +0 -1
- package/src/public.js +75 -80
- package/src/router/common/coreservices.js +0 -2
- package/src/router/directives/state-directives.js +24 -30
- package/src/router/directives/state-directives.spec.js +0 -83
- package/src/router/directives/view-directive.js +6 -15
- package/src/router/directives/view-directive.spec.js +25 -71
- package/src/router/hooks/lazy-load.js +2 -2
- package/src/router/hooks/views.js +3 -5
- package/src/router/resolve/resolvable.js +3 -6
- package/src/router/resolve/resolve-context.js +2 -2
- package/src/router/state/state-service.js +4 -4
- package/src/router/state/state.spec.js +2 -5
- package/src/router/state/views.js +9 -12
- package/src/router/template-factory.js +3 -6
- package/src/router/template-factory.spec.js +0 -4
- package/src/router/transition/transition-hook.js +1 -1
- package/src/router/transition/transition.js +1 -1
- package/src/router/url/url-service.js +2 -8
- package/src/router/url/url-service.spec.js +3 -4
- package/src/router/view-hook.spec.js +2 -2
- package/src/router/view-scroll.js +4 -6
- package/src/services/http/http.js +11 -15
- package/src/services/http/http.spec.js +30 -31
- package/src/services/http/template-request.spec.js +0 -10
- package/src/services/http-backend/http-backend.js +19 -17
- package/src/services/http-backend/http-backend.spec.js +3 -3
- package/src/services/template-request.js +2 -4
- package/src/shared/common.js +6 -10
- package/src/shared/jqlite/jqlite.js +14 -15
- package/src/shared/jqlite/jqlite.spec.js +2 -2
- package/src/shared/utils.js +15 -92
- package/types/core/cache/cache.d.ts +1 -1
- package/types/core/model/model.d.ts +204 -0
- package/types/core/parse/parse.d.ts +26 -0
- package/types/core/scope/scope.d.ts +22 -21
- package/types/directive/channel/channel.d.ts +11 -0
- package/types/directive/form/form.d.ts +1 -0
- package/types/shared/common.d.ts +0 -1
- package/types/shared/utils.d.ts +0 -35
- package/src/core/interval/interval-factory.js +0 -50
- package/src/core/interval/interval.js +0 -77
- package/src/core/interval/interval.md +0 -123
- package/src/core/interval/interval.spec.js +0 -280
- package/src/core/q/q.js +0 -472
- package/src/core/q/q.md +0 -211
- package/src/core/q/q.spec.js +0 -2748
- package/src/core/timeout/timeout.js +0 -109
- package/src/core/timeout/timeout.spec.js +0 -354
- package/src/core/timeout/timout.test.js +0 -12
- package/src/directive/list/list.html +0 -18
- package/src/directive/list/list.js +0 -46
- package/src/directive/list/list.md +0 -22
- package/src/directive/list/list.spec.js +0 -172
- package/types/directive/list/list.d.ts +0 -4
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Angular } from "../../loader";
|
|
2
2
|
import { dealoc, JQLite } from "../../shared/jqlite/jqlite";
|
|
3
3
|
import { EMAIL_REGEXP, ISO_DATE_REGEXP, URL_REGEXP } from "./input";
|
|
4
|
-
import { forEach } from "../../shared/utils";
|
|
5
4
|
|
|
6
5
|
describe("input", () => {
|
|
7
6
|
let $compile;
|
|
@@ -68,7 +67,6 @@ describe("input", () => {
|
|
|
68
67
|
},
|
|
69
68
|
});
|
|
70
69
|
$compile(input)(scope);
|
|
71
|
-
scope.$digest();
|
|
72
70
|
expect(setterCalls).toBe(0);
|
|
73
71
|
});
|
|
74
72
|
|
|
@@ -112,7 +110,6 @@ describe("input", () => {
|
|
|
112
110
|
expect(scope.form.nameA.$name).toBe("nameA");
|
|
113
111
|
const oldModel = scope.form.nameA;
|
|
114
112
|
scope.nameID = "B";
|
|
115
|
-
scope.$digest();
|
|
116
113
|
expect(scope.form.nameA).toBeUndefined();
|
|
117
114
|
expect(scope.form.nameB).toBe(oldModel);
|
|
118
115
|
expect(scope.form.nameB.$name).toBe("nameB");
|
|
@@ -127,7 +124,6 @@ describe("input", () => {
|
|
|
127
124
|
expect(model.$name).toBe("nameA");
|
|
128
125
|
|
|
129
126
|
scope.nameID = "B";
|
|
130
|
-
scope.$digest();
|
|
131
127
|
expect(model.$name).toBe("nameB");
|
|
132
128
|
});
|
|
133
129
|
});
|
|
@@ -432,8 +428,6 @@ describe("input", () => {
|
|
|
432
428
|
it("should validate if min is empty", () => {
|
|
433
429
|
scope.minVal = undefined;
|
|
434
430
|
scope.value = "2014-01";
|
|
435
|
-
scope.$digest();
|
|
436
|
-
|
|
437
431
|
expect(scope.form.alias.$error.min).toBeFalsy();
|
|
438
432
|
});
|
|
439
433
|
});
|
|
@@ -476,8 +470,6 @@ describe("input", () => {
|
|
|
476
470
|
expect(scope.form.alias.$error.max).toBeFalsy();
|
|
477
471
|
|
|
478
472
|
scope.maxVal = "2012-01";
|
|
479
|
-
scope.$digest();
|
|
480
|
-
|
|
481
473
|
expect(
|
|
482
474
|
inputElm.find("input")[0].classList.contains("ng-invalid"),
|
|
483
475
|
).toBeTrue();
|
|
@@ -487,8 +479,6 @@ describe("input", () => {
|
|
|
487
479
|
it("should validate if max is empty", () => {
|
|
488
480
|
scope.maxVal = undefined;
|
|
489
481
|
scope.value = "2012-03";
|
|
490
|
-
scope.$digest();
|
|
491
|
-
|
|
492
482
|
expect(scope.form.alias.$error.max).toBeFalsy();
|
|
493
483
|
});
|
|
494
484
|
});
|
|
@@ -621,8 +611,6 @@ describe("input", () => {
|
|
|
621
611
|
expect(scope.form.alias.$error.min).toBeFalsy();
|
|
622
612
|
|
|
623
613
|
scope.minVal = "2014-W01";
|
|
624
|
-
scope.$digest();
|
|
625
|
-
|
|
626
614
|
expect(
|
|
627
615
|
inputElm.find("input")[0].classList.contains("ng-invalid"),
|
|
628
616
|
).toBeTrue();
|
|
@@ -632,8 +620,6 @@ describe("input", () => {
|
|
|
632
620
|
it("should validate if min is empty", () => {
|
|
633
621
|
scope.minVal = undefined;
|
|
634
622
|
scope.value = "2013-W03";
|
|
635
|
-
scope.$digest();
|
|
636
|
-
|
|
637
623
|
expect(scope.form.alias.$error.min).toBeFalsy();
|
|
638
624
|
});
|
|
639
625
|
});
|
|
@@ -677,8 +663,6 @@ describe("input", () => {
|
|
|
677
663
|
expect(scope.form.alias.$error.max).toBeFalsy();
|
|
678
664
|
|
|
679
665
|
scope.maxVal = "2012-W01";
|
|
680
|
-
scope.$digest();
|
|
681
|
-
|
|
682
666
|
expect(
|
|
683
667
|
inputElm.find("input")[0].classList.contains("ng-invalid"),
|
|
684
668
|
).toBeTrue();
|
|
@@ -688,8 +672,6 @@ describe("input", () => {
|
|
|
688
672
|
it("should validate if max is empty", () => {
|
|
689
673
|
scope.maxVal = undefined;
|
|
690
674
|
scope.value = "2012-W01";
|
|
691
|
-
scope.$digest();
|
|
692
|
-
|
|
693
675
|
expect(scope.form.alias.$error.max).toBeFalsy();
|
|
694
676
|
});
|
|
695
677
|
});
|
|
@@ -824,8 +806,6 @@ describe("input", () => {
|
|
|
824
806
|
expect(scope.form.alias.$error.min).toBeFalsy();
|
|
825
807
|
|
|
826
808
|
scope.minVal = "2010-01-01T01:02:00";
|
|
827
|
-
scope.$digest();
|
|
828
|
-
|
|
829
809
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
830
810
|
expect(scope.form.alias.$error.min).toBeTruthy();
|
|
831
811
|
});
|
|
@@ -833,8 +813,6 @@ describe("input", () => {
|
|
|
833
813
|
it("should validate if min is empty", () => {
|
|
834
814
|
scope.minVal = undefined;
|
|
835
815
|
scope.value = "2010-01-01T01:02:00";
|
|
836
|
-
scope.$digest();
|
|
837
|
-
|
|
838
816
|
expect(scope.form.alias.$error.min).toBeFalsy();
|
|
839
817
|
});
|
|
840
818
|
});
|
|
@@ -872,8 +850,6 @@ describe("input", () => {
|
|
|
872
850
|
expect(scope.form.alias.$error.max).toBeFalsy();
|
|
873
851
|
|
|
874
852
|
scope.maxVal = "2000-01-01T01:02:00";
|
|
875
|
-
scope.$digest();
|
|
876
|
-
|
|
877
853
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
878
854
|
expect(scope.form.alias.$error.max).toBeTruthy();
|
|
879
855
|
});
|
|
@@ -881,8 +857,6 @@ describe("input", () => {
|
|
|
881
857
|
it("should validate if max is empty", () => {
|
|
882
858
|
scope.maxVal = undefined;
|
|
883
859
|
scope.value = "2000-01-01T01:02:00";
|
|
884
|
-
scope.$digest();
|
|
885
|
-
|
|
886
860
|
expect(scope.form.alias.$error.max).toBeFalsy();
|
|
887
861
|
});
|
|
888
862
|
|
|
@@ -893,8 +867,6 @@ describe("input", () => {
|
|
|
893
867
|
)(scope);
|
|
894
868
|
scope.maxVal = "2013-01-01T00:00:00";
|
|
895
869
|
scope.value = "2012-01-01T00:00:00";
|
|
896
|
-
scope.$digest();
|
|
897
|
-
|
|
898
870
|
expect(scope.form.alias.$error.max).toBeFalsy();
|
|
899
871
|
expect(scope.form.alias.$valid).toBeTruthy();
|
|
900
872
|
|
|
@@ -916,13 +888,9 @@ describe("input", () => {
|
|
|
916
888
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
917
889
|
|
|
918
890
|
scope.max = "2001-01-01T01:02:00";
|
|
919
|
-
scope.$digest();
|
|
920
|
-
|
|
921
891
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
922
892
|
|
|
923
893
|
scope.max = "2024-01-01T01:02:00";
|
|
924
|
-
scope.$digest();
|
|
925
|
-
|
|
926
894
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
927
895
|
});
|
|
928
896
|
|
|
@@ -936,13 +904,9 @@ describe("input", () => {
|
|
|
936
904
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
937
905
|
|
|
938
906
|
scope.min = "2014-01-01T01:02:00";
|
|
939
|
-
scope.$digest();
|
|
940
|
-
|
|
941
907
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
942
908
|
|
|
943
909
|
scope.min = "2009-01-01T01:02:00";
|
|
944
|
-
scope.$digest();
|
|
945
|
-
|
|
946
910
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
947
911
|
});
|
|
948
912
|
|
|
@@ -956,13 +920,9 @@ describe("input", () => {
|
|
|
956
920
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
957
921
|
|
|
958
922
|
scope.max = "2001-01-01T01:02:00";
|
|
959
|
-
scope.$digest();
|
|
960
|
-
|
|
961
923
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
962
924
|
|
|
963
925
|
scope.max = "2024-01-01T01:02:00";
|
|
964
|
-
scope.$digest();
|
|
965
|
-
|
|
966
926
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
967
927
|
});
|
|
968
928
|
|
|
@@ -976,13 +936,9 @@ describe("input", () => {
|
|
|
976
936
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
977
937
|
|
|
978
938
|
scope.min = "2014-01-01T01:02:00";
|
|
979
|
-
scope.$digest();
|
|
980
|
-
|
|
981
939
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
982
940
|
|
|
983
941
|
scope.min = "2009-01-01T01:02:00";
|
|
984
|
-
scope.$digest();
|
|
985
|
-
|
|
986
942
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
987
943
|
});
|
|
988
944
|
});
|
|
@@ -1130,8 +1086,6 @@ describe("input", () => {
|
|
|
1130
1086
|
expect(scope.form.alias.$error.min).toBeFalsy();
|
|
1131
1087
|
|
|
1132
1088
|
scope.minVal = "23:55:00";
|
|
1133
|
-
scope.$digest();
|
|
1134
|
-
|
|
1135
1089
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1136
1090
|
expect(scope.form.alias.$error.min).toBeTruthy();
|
|
1137
1091
|
});
|
|
@@ -1139,8 +1093,6 @@ describe("input", () => {
|
|
|
1139
1093
|
it("should validate if min is empty", () => {
|
|
1140
1094
|
scope.minVal = undefined;
|
|
1141
1095
|
scope.value = "23:55:00";
|
|
1142
|
-
scope.$digest();
|
|
1143
|
-
|
|
1144
1096
|
expect(scope.form.alias.$error.min).toBeFalsy();
|
|
1145
1097
|
});
|
|
1146
1098
|
});
|
|
@@ -1174,8 +1126,6 @@ describe("input", () => {
|
|
|
1174
1126
|
it("should validate if max is empty", () => {
|
|
1175
1127
|
scope.maxVal = undefined;
|
|
1176
1128
|
scope.value = "05:30:00";
|
|
1177
|
-
scope.$digest();
|
|
1178
|
-
|
|
1179
1129
|
expect(scope.form.alias.$error.max).toBeFalsy();
|
|
1180
1130
|
});
|
|
1181
1131
|
});
|
|
@@ -1191,8 +1141,6 @@ describe("input", () => {
|
|
|
1191
1141
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1192
1142
|
|
|
1193
1143
|
scope.max = "06:34:00";
|
|
1194
|
-
scope.$digest();
|
|
1195
|
-
|
|
1196
1144
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1197
1145
|
});
|
|
1198
1146
|
|
|
@@ -1207,8 +1155,6 @@ describe("input", () => {
|
|
|
1207
1155
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1208
1156
|
|
|
1209
1157
|
scope.min = "05:50:00";
|
|
1210
|
-
scope.$digest();
|
|
1211
|
-
|
|
1212
1158
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1213
1159
|
});
|
|
1214
1160
|
|
|
@@ -1223,8 +1169,6 @@ describe("input", () => {
|
|
|
1223
1169
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1224
1170
|
|
|
1225
1171
|
scope.max = "06:34:00";
|
|
1226
|
-
scope.$digest();
|
|
1227
|
-
|
|
1228
1172
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1229
1173
|
});
|
|
1230
1174
|
|
|
@@ -1239,8 +1183,6 @@ describe("input", () => {
|
|
|
1239
1183
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1240
1184
|
|
|
1241
1185
|
scope.min = "05:50:00";
|
|
1242
|
-
scope.$digest();
|
|
1243
|
-
|
|
1244
1186
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1245
1187
|
});
|
|
1246
1188
|
});
|
|
@@ -1355,8 +1297,6 @@ describe("input", () => {
|
|
|
1355
1297
|
inputElm = formElm.find("input");
|
|
1356
1298
|
|
|
1357
1299
|
scope.value = "2000-01-01";
|
|
1358
|
-
scope.$digest();
|
|
1359
|
-
|
|
1360
1300
|
expect(scope.form.alias.$error.min).toBeFalsy();
|
|
1361
1301
|
});
|
|
1362
1302
|
});
|
|
@@ -1395,8 +1335,6 @@ describe("input", () => {
|
|
|
1395
1335
|
|
|
1396
1336
|
scope.value = "2020-01-01";
|
|
1397
1337
|
scope.max = new Date(2014, 10, 10, 0, 0, 0).toISOString();
|
|
1398
|
-
scope.$digest();
|
|
1399
|
-
|
|
1400
1338
|
expect(scope.form.myControl.$error.max).toBeTruthy();
|
|
1401
1339
|
});
|
|
1402
1340
|
|
|
@@ -1406,8 +1344,6 @@ describe("input", () => {
|
|
|
1406
1344
|
)(scope);
|
|
1407
1345
|
|
|
1408
1346
|
scope.value = "2020-01-01";
|
|
1409
|
-
scope.$digest();
|
|
1410
|
-
|
|
1411
1347
|
expect(scope.form.alias.$error.max).toBeFalsy();
|
|
1412
1348
|
});
|
|
1413
1349
|
});
|
|
@@ -1423,13 +1359,9 @@ describe("input", () => {
|
|
|
1423
1359
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1424
1360
|
|
|
1425
1361
|
scope.max = "2001-01-01";
|
|
1426
|
-
scope.$digest();
|
|
1427
|
-
|
|
1428
1362
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1429
1363
|
|
|
1430
1364
|
scope.max = "2021-01-01";
|
|
1431
|
-
scope.$digest();
|
|
1432
|
-
|
|
1433
1365
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1434
1366
|
});
|
|
1435
1367
|
|
|
@@ -1444,13 +1376,9 @@ describe("input", () => {
|
|
|
1444
1376
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1445
1377
|
|
|
1446
1378
|
scope.min = "2014-01-01";
|
|
1447
|
-
scope.$digest();
|
|
1448
|
-
|
|
1449
1379
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1450
1380
|
|
|
1451
1381
|
scope.min = "2009-01-01";
|
|
1452
|
-
scope.$digest();
|
|
1453
|
-
|
|
1454
1382
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1455
1383
|
});
|
|
1456
1384
|
|
|
@@ -1465,13 +1393,9 @@ describe("input", () => {
|
|
|
1465
1393
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1466
1394
|
|
|
1467
1395
|
scope.max = "2001-01-01";
|
|
1468
|
-
scope.$digest();
|
|
1469
|
-
|
|
1470
1396
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1471
1397
|
|
|
1472
1398
|
scope.max = "2021-01-01";
|
|
1473
|
-
scope.$digest();
|
|
1474
|
-
|
|
1475
1399
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1476
1400
|
});
|
|
1477
1401
|
|
|
@@ -1486,13 +1410,9 @@ describe("input", () => {
|
|
|
1486
1410
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1487
1411
|
|
|
1488
1412
|
scope.min = "2014-01-01";
|
|
1489
|
-
scope.$digest();
|
|
1490
|
-
|
|
1491
1413
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1492
1414
|
|
|
1493
1415
|
scope.min = "2009-01-01";
|
|
1494
|
-
scope.$digest();
|
|
1495
|
-
|
|
1496
1416
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1497
1417
|
});
|
|
1498
1418
|
|
|
@@ -1507,13 +1427,9 @@ describe("input", () => {
|
|
|
1507
1427
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1508
1428
|
|
|
1509
1429
|
scope.max = new Date(2013, 1, 1, 1, 2, 0);
|
|
1510
|
-
scope.$digest();
|
|
1511
|
-
|
|
1512
1430
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1513
1431
|
|
|
1514
1432
|
scope.max = new Date(2014, 1, 1, 1, 2, 0);
|
|
1515
|
-
scope.$digest();
|
|
1516
|
-
|
|
1517
1433
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1518
1434
|
});
|
|
1519
1435
|
|
|
@@ -1528,13 +1444,9 @@ describe("input", () => {
|
|
|
1528
1444
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1529
1445
|
|
|
1530
1446
|
scope.min = new Date(2014, 1, 1, 1, 2, 0);
|
|
1531
|
-
scope.$digest();
|
|
1532
|
-
|
|
1533
1447
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1534
1448
|
|
|
1535
1449
|
scope.min = new Date(2009, 1, 1, 1, 2, 0);
|
|
1536
|
-
scope.$digest();
|
|
1537
|
-
|
|
1538
1450
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1539
1451
|
});
|
|
1540
1452
|
|
|
@@ -1745,7 +1657,6 @@ describe("input", () => {
|
|
|
1745
1657
|
scope.value = "one";
|
|
1746
1658
|
expect(() => {
|
|
1747
1659
|
$compile('<input type="number" ng-model="value" />')(scope);
|
|
1748
|
-
scope.$digest();
|
|
1749
1660
|
}).toThrowError(/numfmt/);
|
|
1750
1661
|
});
|
|
1751
1662
|
|
|
@@ -1903,23 +1814,18 @@ describe("input", () => {
|
|
|
1903
1814
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1904
1815
|
|
|
1905
1816
|
scope.min = 10;
|
|
1906
|
-
scope.$digest();
|
|
1907
1817
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1908
1818
|
|
|
1909
1819
|
scope.min = 20;
|
|
1910
|
-
scope.$digest();
|
|
1911
1820
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1912
1821
|
|
|
1913
1822
|
scope.min = null;
|
|
1914
|
-
scope.$digest();
|
|
1915
1823
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1916
1824
|
|
|
1917
1825
|
scope.min = "20";
|
|
1918
|
-
scope.$digest();
|
|
1919
1826
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1920
1827
|
|
|
1921
1828
|
scope.min = "abc";
|
|
1922
|
-
scope.$digest();
|
|
1923
1829
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1924
1830
|
});
|
|
1925
1831
|
});
|
|
@@ -1980,23 +1886,18 @@ describe("input", () => {
|
|
|
1980
1886
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1981
1887
|
|
|
1982
1888
|
scope.min = 10;
|
|
1983
|
-
scope.$digest();
|
|
1984
1889
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1985
1890
|
|
|
1986
1891
|
scope.min = 20;
|
|
1987
|
-
scope.$digest();
|
|
1988
1892
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1989
1893
|
|
|
1990
1894
|
scope.min = null;
|
|
1991
|
-
scope.$digest();
|
|
1992
1895
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
1993
1896
|
|
|
1994
1897
|
scope.min = "20";
|
|
1995
|
-
scope.$digest();
|
|
1996
1898
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
1997
1899
|
|
|
1998
1900
|
scope.min = "abc";
|
|
1999
|
-
scope.$digest();
|
|
2000
1901
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2001
1902
|
});
|
|
2002
1903
|
});
|
|
@@ -2058,23 +1959,18 @@ describe("input", () => {
|
|
|
2058
1959
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2059
1960
|
|
|
2060
1961
|
scope.max = 10;
|
|
2061
|
-
scope.$digest();
|
|
2062
1962
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2063
1963
|
|
|
2064
1964
|
scope.max = 0;
|
|
2065
|
-
scope.$digest();
|
|
2066
1965
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2067
1966
|
|
|
2068
1967
|
scope.max = null;
|
|
2069
|
-
scope.$digest();
|
|
2070
1968
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2071
1969
|
|
|
2072
1970
|
scope.max = "4";
|
|
2073
|
-
scope.$digest();
|
|
2074
1971
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2075
1972
|
|
|
2076
1973
|
scope.max = "abc";
|
|
2077
|
-
scope.$digest();
|
|
2078
1974
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2079
1975
|
});
|
|
2080
1976
|
});
|
|
@@ -2136,218 +2032,210 @@ describe("input", () => {
|
|
|
2136
2032
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2137
2033
|
|
|
2138
2034
|
scope.max = 10;
|
|
2139
|
-
scope.$digest();
|
|
2140
2035
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2141
2036
|
|
|
2142
2037
|
scope.max = 0;
|
|
2143
|
-
scope.$digest();
|
|
2144
2038
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2145
2039
|
|
|
2146
2040
|
scope.max = null;
|
|
2147
|
-
scope.$digest();
|
|
2148
2041
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2149
2042
|
|
|
2150
2043
|
scope.max = "4";
|
|
2151
|
-
scope.$digest();
|
|
2152
2044
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2153
2045
|
|
|
2154
2046
|
scope.max = "abc";
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
expect(inputElm.val()).toBe("12");
|
|
2197
|
-
expect(scope.value).toBe(12);
|
|
2198
|
-
expect(scope.form.alias.$error.step).toBeTruthy();
|
|
2199
|
-
});
|
|
2200
|
-
|
|
2201
|
-
it("should validate even if the step value changes on-the-fly", () => {
|
|
2202
|
-
scope.step = 10;
|
|
2203
|
-
const formElm = $compile(
|
|
2204
|
-
`<form name="form"><input type="number" ng-model="value" name="alias" ${attrHtml} /></form>`,
|
|
2205
|
-
)(scope);
|
|
2206
|
-
inputElm = formElm.find("input");
|
|
2207
|
-
inputElm[0].value = "10";
|
|
2208
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2209
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2210
|
-
expect(scope.value).toBe(10);
|
|
2211
|
-
|
|
2212
|
-
// Step changes, but value matches
|
|
2213
|
-
scope.$apply("step = 5");
|
|
2214
|
-
expect(inputElm.val()).toBe("10");
|
|
2215
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2216
|
-
expect(scope.value).toBe(10);
|
|
2217
|
-
expect(scope.form.alias.$error.step).toBeFalsy();
|
|
2218
|
-
|
|
2219
|
-
// Step changes, value does not match
|
|
2220
|
-
scope.$apply("step = 6");
|
|
2221
|
-
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2222
|
-
expect(scope.value).toBeUndefined();
|
|
2223
|
-
expect(inputElm.val()).toBe("10");
|
|
2224
|
-
expect(scope.form.alias.$error.step).toBeTruthy();
|
|
2225
|
-
|
|
2226
|
-
// null = valid
|
|
2227
|
-
scope.$apply("step = null");
|
|
2228
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2229
|
-
expect(scope.value).toBe(10);
|
|
2230
|
-
expect(inputElm.val()).toBe("10");
|
|
2231
|
-
expect(scope.form.alias.$error.step).toBeFalsy();
|
|
2232
|
-
|
|
2233
|
-
// Step val as string
|
|
2234
|
-
scope.$apply('step = "7"');
|
|
2235
|
-
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2236
|
-
expect(scope.value).toBeUndefined();
|
|
2237
|
-
expect(inputElm.val()).toBe("10");
|
|
2238
|
-
expect(scope.form.alias.$error.step).toBeTruthy();
|
|
2239
|
-
|
|
2240
|
-
// unparsable string is ignored
|
|
2241
|
-
scope.$apply('step = "abc"');
|
|
2242
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2243
|
-
expect(scope.value).toBe(10);
|
|
2244
|
-
expect(inputElm.val()).toBe("10");
|
|
2245
|
-
expect(scope.form.alias.$error.step).toBeFalsy();
|
|
2246
|
-
});
|
|
2247
|
-
|
|
2248
|
-
it('should use the correct "step base" when `[min]` is specified', () => {
|
|
2249
|
-
scope.min = 5;
|
|
2250
|
-
scope.step = 10;
|
|
2251
|
-
scope.value = 10;
|
|
2252
|
-
inputElm = $compile(
|
|
2253
|
-
`<input type="number" ng-model="value" min="{{min}}" ${attrHtml} />`,
|
|
2254
|
-
)(scope);
|
|
2255
|
-
const ngModel = inputElm.controller("ngModel");
|
|
2256
|
-
scope.$digest();
|
|
2257
|
-
expect(inputElm.val()).toBe("10");
|
|
2258
|
-
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2259
|
-
expect(ngModel.$error.step).toBe(true);
|
|
2260
|
-
expect(scope.value).toBe(10); // an initially invalid value should not be changed
|
|
2261
|
-
|
|
2262
|
-
inputElm[0].value = "15";
|
|
2263
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2264
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2265
|
-
expect(scope.value).toBe(15);
|
|
2266
|
-
|
|
2267
|
-
scope.$apply("step = 3");
|
|
2268
|
-
expect(inputElm.val()).toBe("15");
|
|
2269
|
-
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2270
|
-
expect(ngModel.$error.step).toBe(true);
|
|
2271
|
-
expect(scope.value).toBeUndefined();
|
|
2272
|
-
|
|
2273
|
-
inputElm[0].value = "8";
|
|
2274
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2275
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2276
|
-
expect(scope.value).toBe(8);
|
|
2277
|
-
|
|
2278
|
-
scope.$apply("min = 10; step = 20");
|
|
2279
|
-
inputElm[0].value = "30";
|
|
2280
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2281
|
-
expect(inputElm.val()).toBe("30");
|
|
2282
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2283
|
-
expect(scope.value).toBe(30);
|
|
2284
|
-
|
|
2285
|
-
scope.$apply("min = 5");
|
|
2286
|
-
expect(inputElm.val()).toBe("30");
|
|
2287
|
-
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2288
|
-
expect(ngModel.$error.step).toBe(true);
|
|
2289
|
-
expect(scope.value).toBeUndefined();
|
|
2290
|
-
|
|
2291
|
-
scope.$apply("step = 0.00000001");
|
|
2292
|
-
expect(inputElm.val()).toBe("30");
|
|
2293
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2294
|
-
expect(scope.value).toBe(30);
|
|
2295
|
-
|
|
2296
|
-
// 0.3 - 0.2 === 0.09999999999999998
|
|
2297
|
-
scope.$apply("min = 0.2; step = (0.3 - 0.2)");
|
|
2298
|
-
inputElm[0].value = "0.3";
|
|
2299
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2300
|
-
expect(inputElm.val()).toBe("0.3");
|
|
2301
|
-
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2302
|
-
expect(ngModel.$error.step).toBe(true);
|
|
2303
|
-
expect(scope.value).toBeUndefined();
|
|
2304
|
-
});
|
|
2305
|
-
|
|
2306
|
-
it("should correctly validate even in cases where the JS floating point arithmetic fails", () => {
|
|
2307
|
-
scope.step = 0.1;
|
|
2308
|
-
inputElm = $compile(
|
|
2309
|
-
`<input type="number" ng-model="value" ${attrHtml} />`,
|
|
2310
|
-
)(scope);
|
|
2311
|
-
const ngModel = inputElm.controller("ngModel");
|
|
2312
|
-
|
|
2313
|
-
expect(inputElm.val()).toBe("");
|
|
2314
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2315
|
-
expect(scope.value).toBeUndefined();
|
|
2316
|
-
|
|
2317
|
-
inputElm[0].value = "0.3";
|
|
2318
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2319
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2320
|
-
expect(scope.value).toBe(0.3);
|
|
2321
|
-
|
|
2322
|
-
inputElm[0].value = "2.9999999999999996";
|
|
2323
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2324
|
-
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2325
|
-
expect(ngModel.$error.step).toBe(true);
|
|
2326
|
-
expect(scope.value).toBeUndefined();
|
|
2327
|
-
|
|
2328
|
-
// 0.5 % 0.1 === 0.09999999999999998
|
|
2329
|
-
inputElm[0].value = "0.5";
|
|
2330
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2331
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2332
|
-
expect(scope.value).toBe(0.5);
|
|
2333
|
-
|
|
2334
|
-
// // 3.5 % 0.1 === 0.09999999999999981
|
|
2335
|
-
inputElm[0].value = "3.5";
|
|
2336
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2337
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2338
|
-
expect(scope.value).toBe(3.5);
|
|
2339
|
-
|
|
2340
|
-
// 1.16 % 0.01 === 0.009999999999999896
|
|
2341
|
-
// 1.16 * 100 === 115.99999999999999
|
|
2342
|
-
scope.step = 0.01;
|
|
2343
|
-
inputElm[0].value = "1.16";
|
|
2344
|
-
inputElm[0].dispatchEvent(new Event("change"));
|
|
2345
|
-
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2346
|
-
expect(scope.value).toBe(1.16);
|
|
2347
|
-
});
|
|
2047
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2048
|
+
});
|
|
2049
|
+
});
|
|
2050
|
+
|
|
2051
|
+
Object.entries({
|
|
2052
|
+
step: 'step="{{step}}"',
|
|
2053
|
+
ngStep: 'ng-step="step"',
|
|
2054
|
+
}).forEach(([attrName, attrHtml]) => {
|
|
2055
|
+
describe(attrName, () => {
|
|
2056
|
+
it("should validate", () => {
|
|
2057
|
+
scope.step = 10;
|
|
2058
|
+
scope.value = 20;
|
|
2059
|
+
const formElm = $compile(
|
|
2060
|
+
`<form name="form"><input type="number" ng-model="value" name="alias" ${attrHtml} /></form>`,
|
|
2061
|
+
)(scope);
|
|
2062
|
+
inputElm = formElm.find("input");
|
|
2063
|
+
scope.$digest();
|
|
2064
|
+
expect(inputElm.val()).toBe("20");
|
|
2065
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2066
|
+
expect(scope.value).toBe(20);
|
|
2067
|
+
expect(scope.form.alias.$error.step).toBeFalsy();
|
|
2068
|
+
|
|
2069
|
+
inputElm[0].value = "18";
|
|
2070
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2071
|
+
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2072
|
+
expect(inputElm.val()).toBe("18");
|
|
2073
|
+
expect(scope.value).toBeUndefined();
|
|
2074
|
+
expect(scope.form.alias.$error.step).toBeTruthy();
|
|
2075
|
+
|
|
2076
|
+
inputElm[0].value = "10";
|
|
2077
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2078
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2079
|
+
expect(inputElm.val()).toBe("10");
|
|
2080
|
+
expect(scope.value).toBe(10);
|
|
2081
|
+
expect(scope.form.alias.$error.step).toBeFalsy();
|
|
2082
|
+
|
|
2083
|
+
scope.$apply("value = 12");
|
|
2084
|
+
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2085
|
+
expect(inputElm.val()).toBe("12");
|
|
2086
|
+
expect(scope.value).toBe(12);
|
|
2087
|
+
expect(scope.form.alias.$error.step).toBeTruthy();
|
|
2348
2088
|
});
|
|
2349
|
-
|
|
2350
|
-
|
|
2089
|
+
|
|
2090
|
+
it("should validate even if the step value changes on-the-fly", () => {
|
|
2091
|
+
scope.step = 10;
|
|
2092
|
+
const formElm = $compile(
|
|
2093
|
+
`<form name="form"><input type="number" ng-model="value" name="alias" ${attrHtml} /></form>`,
|
|
2094
|
+
)(scope);
|
|
2095
|
+
inputElm = formElm.find("input");
|
|
2096
|
+
inputElm[0].value = "10";
|
|
2097
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2098
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2099
|
+
expect(scope.value).toBe(10);
|
|
2100
|
+
|
|
2101
|
+
// Step changes, but value matches
|
|
2102
|
+
scope.$apply("step = 5");
|
|
2103
|
+
expect(inputElm.val()).toBe("10");
|
|
2104
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2105
|
+
expect(scope.value).toBe(10);
|
|
2106
|
+
expect(scope.form.alias.$error.step).toBeFalsy();
|
|
2107
|
+
|
|
2108
|
+
// Step changes, value does not match
|
|
2109
|
+
scope.$apply("step = 6");
|
|
2110
|
+
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2111
|
+
expect(scope.value).toBeUndefined();
|
|
2112
|
+
expect(inputElm.val()).toBe("10");
|
|
2113
|
+
expect(scope.form.alias.$error.step).toBeTruthy();
|
|
2114
|
+
|
|
2115
|
+
// null = valid
|
|
2116
|
+
scope.$apply("step = null");
|
|
2117
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2118
|
+
expect(scope.value).toBe(10);
|
|
2119
|
+
expect(inputElm.val()).toBe("10");
|
|
2120
|
+
expect(scope.form.alias.$error.step).toBeFalsy();
|
|
2121
|
+
|
|
2122
|
+
// Step val as string
|
|
2123
|
+
scope.$apply('step = "7"');
|
|
2124
|
+
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2125
|
+
expect(scope.value).toBeUndefined();
|
|
2126
|
+
expect(inputElm.val()).toBe("10");
|
|
2127
|
+
expect(scope.form.alias.$error.step).toBeTruthy();
|
|
2128
|
+
|
|
2129
|
+
// unparsable string is ignored
|
|
2130
|
+
scope.$apply('step = "abc"');
|
|
2131
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2132
|
+
expect(scope.value).toBe(10);
|
|
2133
|
+
expect(inputElm.val()).toBe("10");
|
|
2134
|
+
expect(scope.form.alias.$error.step).toBeFalsy();
|
|
2135
|
+
});
|
|
2136
|
+
|
|
2137
|
+
it('should use the correct "step base" when `[min]` is specified', () => {
|
|
2138
|
+
scope.min = 5;
|
|
2139
|
+
scope.step = 10;
|
|
2140
|
+
scope.value = 10;
|
|
2141
|
+
inputElm = $compile(
|
|
2142
|
+
`<input type="number" ng-model="value" min="{{min}}" ${attrHtml} />`,
|
|
2143
|
+
)(scope);
|
|
2144
|
+
const ngModel = inputElm.controller("ngModel");
|
|
2145
|
+
scope.$digest();
|
|
2146
|
+
expect(inputElm.val()).toBe("10");
|
|
2147
|
+
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2148
|
+
expect(ngModel.$error.step).toBe(true);
|
|
2149
|
+
expect(scope.value).toBe(10); // an initially invalid value should not be changed
|
|
2150
|
+
|
|
2151
|
+
inputElm[0].value = "15";
|
|
2152
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2153
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2154
|
+
expect(scope.value).toBe(15);
|
|
2155
|
+
|
|
2156
|
+
scope.$apply("step = 3");
|
|
2157
|
+
expect(inputElm.val()).toBe("15");
|
|
2158
|
+
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2159
|
+
expect(ngModel.$error.step).toBe(true);
|
|
2160
|
+
expect(scope.value).toBeUndefined();
|
|
2161
|
+
|
|
2162
|
+
inputElm[0].value = "8";
|
|
2163
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2164
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2165
|
+
expect(scope.value).toBe(8);
|
|
2166
|
+
|
|
2167
|
+
scope.$apply("min = 10; step = 20");
|
|
2168
|
+
inputElm[0].value = "30";
|
|
2169
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2170
|
+
expect(inputElm.val()).toBe("30");
|
|
2171
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2172
|
+
expect(scope.value).toBe(30);
|
|
2173
|
+
|
|
2174
|
+
scope.$apply("min = 5");
|
|
2175
|
+
expect(inputElm.val()).toBe("30");
|
|
2176
|
+
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2177
|
+
expect(ngModel.$error.step).toBe(true);
|
|
2178
|
+
expect(scope.value).toBeUndefined();
|
|
2179
|
+
|
|
2180
|
+
scope.$apply("step = 0.00000001");
|
|
2181
|
+
expect(inputElm.val()).toBe("30");
|
|
2182
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2183
|
+
expect(scope.value).toBe(30);
|
|
2184
|
+
|
|
2185
|
+
// 0.3 - 0.2 === 0.09999999999999998
|
|
2186
|
+
scope.$apply("min = 0.2; step = (0.3 - 0.2)");
|
|
2187
|
+
inputElm[0].value = "0.3";
|
|
2188
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2189
|
+
expect(inputElm.val()).toBe("0.3");
|
|
2190
|
+
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2191
|
+
expect(ngModel.$error.step).toBe(true);
|
|
2192
|
+
expect(scope.value).toBeUndefined();
|
|
2193
|
+
});
|
|
2194
|
+
|
|
2195
|
+
it("should correctly validate even in cases where the JS floating point arithmetic fails", () => {
|
|
2196
|
+
scope.step = 0.1;
|
|
2197
|
+
inputElm = $compile(
|
|
2198
|
+
`<input type="number" ng-model="value" ${attrHtml} />`,
|
|
2199
|
+
)(scope);
|
|
2200
|
+
const ngModel = inputElm.controller("ngModel");
|
|
2201
|
+
|
|
2202
|
+
expect(inputElm.val()).toBe("");
|
|
2203
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2204
|
+
expect(scope.value).toBeUndefined();
|
|
2205
|
+
|
|
2206
|
+
inputElm[0].value = "0.3";
|
|
2207
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2208
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2209
|
+
expect(scope.value).toBe(0.3);
|
|
2210
|
+
|
|
2211
|
+
inputElm[0].value = "2.9999999999999996";
|
|
2212
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2213
|
+
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
2214
|
+
expect(ngModel.$error.step).toBe(true);
|
|
2215
|
+
expect(scope.value).toBeUndefined();
|
|
2216
|
+
|
|
2217
|
+
// 0.5 % 0.1 === 0.09999999999999998
|
|
2218
|
+
inputElm[0].value = "0.5";
|
|
2219
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2220
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2221
|
+
expect(scope.value).toBe(0.5);
|
|
2222
|
+
|
|
2223
|
+
// // 3.5 % 0.1 === 0.09999999999999981
|
|
2224
|
+
inputElm[0].value = "3.5";
|
|
2225
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2226
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2227
|
+
expect(scope.value).toBe(3.5);
|
|
2228
|
+
|
|
2229
|
+
// 1.16 % 0.01 === 0.009999999999999896
|
|
2230
|
+
// 1.16 * 100 === 115.99999999999999
|
|
2231
|
+
scope.step = 0.01;
|
|
2232
|
+
inputElm[0].value = "1.16";
|
|
2233
|
+
inputElm[0].dispatchEvent(new Event("change"));
|
|
2234
|
+
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2235
|
+
expect(scope.value).toBe(1.16);
|
|
2236
|
+
});
|
|
2237
|
+
});
|
|
2238
|
+
});
|
|
2351
2239
|
|
|
2352
2240
|
describe("required", () => {
|
|
2353
2241
|
it("should be valid even if value is 0", () => {
|
|
@@ -2658,7 +2546,6 @@ describe("input", () => {
|
|
|
2658
2546
|
expect(() => {
|
|
2659
2547
|
scope.value = "one";
|
|
2660
2548
|
inputElm = $compile('<input type="range" ng-model="value" />')(scope);
|
|
2661
|
-
scope.$digest();
|
|
2662
2549
|
}).toThrowError(/numfmt/);
|
|
2663
2550
|
});
|
|
2664
2551
|
|
|
@@ -2670,8 +2557,6 @@ describe("input", () => {
|
|
|
2670
2557
|
'<form name="form"><input type="range" ng-model="value" name="alias" min="{{min}}" /></form>',
|
|
2671
2558
|
)(scope);
|
|
2672
2559
|
inputElm = formElm.find("input");
|
|
2673
|
-
scope.$digest();
|
|
2674
|
-
|
|
2675
2560
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2676
2561
|
expect(inputElm.val()).toBe("-3");
|
|
2677
2562
|
expect(scope.value).toBe(-3);
|
|
@@ -2704,8 +2589,6 @@ describe("input", () => {
|
|
|
2704
2589
|
inputElm = $compile(
|
|
2705
2590
|
'<input type="range" ng-model="value" name="alias" min="{{min}}" />',
|
|
2706
2591
|
)(scope);
|
|
2707
|
-
scope.$digest();
|
|
2708
|
-
|
|
2709
2592
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2710
2593
|
expect(inputElm.val()).toBe("0");
|
|
2711
2594
|
expect(scope.value).toBe(0);
|
|
@@ -2722,32 +2605,26 @@ describe("input", () => {
|
|
|
2722
2605
|
inputElm = $compile(
|
|
2723
2606
|
'<input type="range" ng-model="value" name="alias" min="{{min}}" />',
|
|
2724
2607
|
)(scope);
|
|
2725
|
-
scope.$digest();
|
|
2726
|
-
|
|
2727
2608
|
inputElm[0].value = "15";
|
|
2728
2609
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
2729
2610
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2730
2611
|
|
|
2731
2612
|
scope.min = 20;
|
|
2732
|
-
scope.$digest();
|
|
2733
2613
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2734
2614
|
expect(scope.value).toBe(20);
|
|
2735
2615
|
expect(inputElm.val()).toBe("20");
|
|
2736
2616
|
|
|
2737
2617
|
scope.min = null;
|
|
2738
|
-
scope.$digest();
|
|
2739
2618
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2740
2619
|
expect(scope.value).toBe(20);
|
|
2741
2620
|
expect(inputElm.val()).toBe("20");
|
|
2742
2621
|
|
|
2743
2622
|
scope.min = "15";
|
|
2744
|
-
scope.$digest();
|
|
2745
2623
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2746
2624
|
expect(scope.value).toBe(20);
|
|
2747
2625
|
expect(inputElm.val()).toBe("20");
|
|
2748
2626
|
|
|
2749
2627
|
scope.min = "abc";
|
|
2750
|
-
scope.$digest();
|
|
2751
2628
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2752
2629
|
expect(scope.value).toBe(20);
|
|
2753
2630
|
expect(inputElm.val()).toBe("20");
|
|
@@ -2763,7 +2640,6 @@ describe("input", () => {
|
|
|
2763
2640
|
'<form name="form"><input type="range" ng-model="value" name="alias" max="{{max}}" /></form>',
|
|
2764
2641
|
)(scope);
|
|
2765
2642
|
inputElm = formElm.find("input");
|
|
2766
|
-
scope.$digest();
|
|
2767
2643
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2768
2644
|
expect(inputElm.val()).toBe("130");
|
|
2769
2645
|
expect(scope.value).toBe(130);
|
|
@@ -2795,7 +2671,6 @@ describe("input", () => {
|
|
|
2795
2671
|
inputElm = $compile(
|
|
2796
2672
|
'<input type="range" ng-model="value" name="alias" max="{{max}}" />',
|
|
2797
2673
|
)(scope);
|
|
2798
|
-
scope.$digest();
|
|
2799
2674
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2800
2675
|
expect(inputElm.val()).toBe("100");
|
|
2801
2676
|
expect(scope.value).toBe(100);
|
|
@@ -2812,31 +2687,26 @@ describe("input", () => {
|
|
|
2812
2687
|
inputElm = $compile(
|
|
2813
2688
|
'<input type="range" ng-model="value" name="alias" max="{{max}}" />',
|
|
2814
2689
|
)(scope);
|
|
2815
|
-
scope.$digest();
|
|
2816
2690
|
inputElm[0].value = "5";
|
|
2817
2691
|
inputElm[0].dispatchEvent(new Event("change"));
|
|
2818
2692
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2819
2693
|
|
|
2820
2694
|
scope.max = 0;
|
|
2821
|
-
scope.$digest();
|
|
2822
2695
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2823
2696
|
expect(scope.value).toBe(0);
|
|
2824
2697
|
expect(inputElm.val()).toBe("0");
|
|
2825
2698
|
|
|
2826
2699
|
scope.max = null;
|
|
2827
|
-
scope.$digest();
|
|
2828
2700
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2829
2701
|
expect(scope.value).toBe(0);
|
|
2830
2702
|
expect(inputElm.val()).toBe("0");
|
|
2831
2703
|
|
|
2832
2704
|
scope.max = "4";
|
|
2833
|
-
scope.$digest();
|
|
2834
2705
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2835
2706
|
expect(scope.value).toBe(0);
|
|
2836
2707
|
expect(inputElm.val()).toBe("0");
|
|
2837
2708
|
|
|
2838
2709
|
scope.max = "abc";
|
|
2839
|
-
scope.$digest();
|
|
2840
2710
|
expect(inputElm[0].classList.contains("ng-valid")).toBeTrue();
|
|
2841
2711
|
expect(scope.value).toBe(0);
|
|
2842
2712
|
expect(inputElm.val()).toBe("0");
|
|
@@ -2850,8 +2720,6 @@ describe("input", () => {
|
|
|
2850
2720
|
inputElm = $compile(
|
|
2851
2721
|
'<input type="range" ng-model="value" name="alias" max="{{max}}" min="{{min}}" />',
|
|
2852
2722
|
)(scope);
|
|
2853
|
-
scope.$digest();
|
|
2854
|
-
|
|
2855
2723
|
expect(inputElm.val()).toBe("60");
|
|
2856
2724
|
expect(scope.value).toBe(60);
|
|
2857
2725
|
});
|
|
@@ -2861,13 +2729,10 @@ describe("input", () => {
|
|
|
2861
2729
|
inputElm = $compile(
|
|
2862
2730
|
'<input type="range" ng-model="value" name="alias" max="{{max}}" min="{{min}}" />',
|
|
2863
2731
|
)(scope);
|
|
2864
|
-
scope.$digest();
|
|
2865
2732
|
expect(inputElm.val()).toBe("70");
|
|
2866
2733
|
expect(scope.value).toBe(70);
|
|
2867
2734
|
|
|
2868
2735
|
scope.max = 20;
|
|
2869
|
-
scope.$digest();
|
|
2870
|
-
|
|
2871
2736
|
expect(inputElm.val()).toBe("40");
|
|
2872
2737
|
expect(scope.value).toBe(40);
|
|
2873
2738
|
});
|
|
@@ -3516,8 +3381,6 @@ describe("input", () => {
|
|
|
3516
3381
|
'<input type="checkbox" required name="cb" ng-model="value" ng-true-value="\'yes\'" />' +
|
|
3517
3382
|
"</form>",
|
|
3518
3383
|
)(scope);
|
|
3519
|
-
scope.$digest();
|
|
3520
|
-
|
|
3521
3384
|
inputElm = formElm.find("input");
|
|
3522
3385
|
|
|
3523
3386
|
expect(inputElm[0].classList.contains("ng-invalid")).toBeTrue();
|
|
@@ -3642,7 +3505,6 @@ describe("input", () => {
|
|
|
3642
3505
|
'<input type="radio" ng-model="selected" ng-value="\'\'">' +
|
|
3643
3506
|
'<input type="radio" ng-model="selected" ng-value="0">',
|
|
3644
3507
|
)(scope);
|
|
3645
|
-
scope.$digest();
|
|
3646
3508
|
expect(inputElm[0].checked).toBe(true);
|
|
3647
3509
|
expect(inputElm[1].checked).toBe(false);
|
|
3648
3510
|
expect(inputElm[2].checked).toBe(false);
|
|
@@ -3678,8 +3540,6 @@ describe("input", () => {
|
|
|
3678
3540
|
scope.selected = 1;
|
|
3679
3541
|
});
|
|
3680
3542
|
|
|
3681
|
-
scope.$digest();
|
|
3682
|
-
|
|
3683
3543
|
expect(inputElm[0].children[0].checked).toBe(true);
|
|
3684
3544
|
expect(inputElm[0].children[1].checked).toBe(false);
|
|
3685
3545
|
|