@@ -45,7 +45,9 @@ describe('formlyNgModelAttrsManipulator', () => {
45
45
expect ( result ) . to . equal ( template ) ;
46
46
} ) ;
47
47
48
- it ( `should allow you to specify a selector for specific elements to skip` , ( ) => {
48
+
49
+ const skipWithSelectorTitle = `should allow you to specify a selector for specific elements to skip` ;
50
+ function skipWithSelector ( ) {
49
51
const className = 'ignored-thing' + _ . random ( 0 , 10 ) ;
50
52
field . templateOptions . required = true ;
51
53
field . extras . skipNgModelAttrsManipulator = `.${ className } ` ;
@@ -59,9 +61,11 @@ describe('formlyNgModelAttrsManipulator', () => {
59
61
const secondInput = angular . element ( resultNode . querySelector ( `.${ className } ` ) ) ;
60
62
expect ( firstInput . attr ( 'required' ) ) . to . exist ;
61
63
expect ( secondInput . attr ( 'required' ) ) . to . not . exist ;
62
- } ) ;
64
+ }
65
+ it ( skipWithSelectorTitle , skipWithSelector ) ;
63
66
64
- it ( `should allow you to place the attribute formly-skip-ng-model-attrs-manipulator on an ng-model to have it skip` , ( ) => {
67
+ const skipWithAttributeTitle = `should allow you to place the attribute formly-skip-ng-model-attrs-manipulator on an ng-model to have it skip` ;
68
+ function skipWithAttribute ( ) {
65
69
field . templateOptions . required = true ;
66
70
manipulate ( `
67
71
<div>
@@ -73,10 +77,12 @@ describe('formlyNgModelAttrsManipulator', () => {
73
77
const secondInput = angular . element ( resultNode . querySelector ( '[formly-skip-ng-model-attrs-manipulator]' ) ) ;
74
78
expect ( firstInput . attr ( 'required' ) ) . to . exist ;
75
79
expect ( secondInput . attr ( 'required' ) ) . to . not . exist ;
76
- } ) ;
80
+ }
81
+ it ( skipWithAttributeTitle , skipWithAttribute ) ;
77
82
78
83
79
- it ( `should not skip by selector if skipNgModelAttrsManipulator is a boolean value` , ( ) => {
84
+ const dontSkipWithBooleanTitle = `should not skip by selector if skipNgModelAttrsManipulator is a boolean value` ;
85
+ function dontSkipWithBoolean ( ) {
80
86
field . templateOptions . required = true ;
81
87
field . extras . skipNgModelAttrsManipulator = false ;
82
88
manipulate ( `
@@ -89,9 +95,11 @@ describe('formlyNgModelAttrsManipulator', () => {
89
95
const secondInput = angular . element ( resultNode . querySelector ( '.second-thing' ) ) ;
90
96
expect ( firstInput . attr ( 'required' ) ) . to . exist ;
91
97
expect ( secondInput . attr ( 'required' ) ) . to . exist ;
92
- } ) ;
98
+ }
99
+ it ( dontSkipWithBooleanTitle , dontSkipWithBoolean ) ;
93
100
94
- it ( `should allow you to skip using both the special attribute and the custom selector` , ( ) => {
101
+ const skipWithAttributeAndSelectorTitle = `should allow you to skip using both the special attribute and the custom selector` ;
102
+ function skipWithAttributeAndSelector ( ) {
95
103
const className = 'ignored-thing' + _ . random ( 0 , 10 ) ;
96
104
field . templateOptions . required = true ;
97
105
field . extras . skipNgModelAttrsManipulator = `.${ className } ` ;
@@ -108,9 +116,37 @@ describe('formlyNgModelAttrsManipulator', () => {
108
116
expect ( firstInput . attr ( 'required' ) ) . to . exist ;
109
117
expect ( secondInput . attr ( 'required' ) ) . to . not . exist ;
110
118
expect ( thirdInput . attr ( 'required' ) ) . to . not . exist ;
119
+ }
120
+ it ( skipWithAttributeAndSelectorTitle , skipWithAttributeAndSelector ) ;
121
+
122
+ //repeat a few skipping tests with a broken Element.querySelectorAll function
123
+ describe ( 'node search fallback' , ( ) => {
124
+ let origQuerySelectorAll ;
125
+
126
+ //deliberately break querySelectorAll to mimic IE8's behaviour
127
+ beforeEach ( ( ) => {
128
+ origQuerySelectorAll = Element . prototype . querySelectorAll ;
129
+ Element . prototype . querySelectorAll = function brokenQuerySelectorAll ( selector ) {
130
+ if ( selector && selector . indexOf ( ':not' ) >= 0 ) {
131
+ throw new Error ( ':not selector not supported' ) ;
132
+ }
133
+ return origQuerySelectorAll . apply ( this , arguments ) ;
134
+ } ;
135
+ } ) ;
136
+
137
+ afterEach ( ( ) => {
138
+ Element . prototype . querySelectorAll = origQuerySelectorAll ;
139
+ } ) ;
140
+
141
+ it ( skipWithSelectorTitle , skipWithSelector ) ;
142
+ it ( skipWithAttributeTitle , skipWithAttribute ) ;
143
+ it ( dontSkipWithBooleanTitle , dontSkipWithBoolean ) ;
144
+ it ( skipWithAttributeAndSelectorTitle , skipWithAttributeAndSelector ) ;
111
145
} ) ;
146
+
112
147
} ) ;
113
148
149
+
114
150
it ( `should have a limited number of automatically added attributes without any specific options` , ( ) => {
115
151
manipulate ( ) ;
116
152
// because different browsers place attributes in different places...
0 commit comments