@@ -23,35 +23,30 @@ define([
2323 } ) ;
2424
2525 it ( 'should not enable inputs that have the disabled CSS class when dependencies are satisfied' , function ( ) {
26- // Container that will be traversed with levels_up = 1
27- var container = document . createElement ( 'div' ) ;
28- document . body . appendChild ( container ) ;
26+ var container = document . createElement ( 'div' ) ,
27+ target = document . createElement ( 'input' ) ,
28+ cssDisabled = document . createElement ( 'input' ) ,
29+ normalInput = document . createElement ( 'input' ) ,
30+ source = document . createElement ( 'input' ) ,
31+ originalObserve = window . Event && window . Event . observe ;
2932
30- // Target element (idTo) inside the container
31- var target = document . createElement ( 'input' ) ;
33+ document . body . appendChild ( container ) ;
3234 target . id = 'test_input_dependent' ;
3335 container . appendChild ( target ) ;
34-
35- // Sibling input that carries CSS class "disabled" and is disabled initially
36- var cssDisabled = document . createElement ( 'input' ) ;
3736 cssDisabled . id = 'css_disabled_input' ;
3837 cssDisabled . className = 'disabled' ;
3938 cssDisabled . disabled = true ;
4039 container . appendChild ( cssDisabled ) ;
41-
42- // Another sibling input which is disabled initially but should be enabled after dependencies are met
43- var normalInput = document . createElement ( 'input' ) ;
4440 normalInput . id = 'normal_input' ;
4541 normalInput . disabled = true ;
4642 container . appendChild ( normalInput ) ;
47-
48- // Dependency source element that satisfies the map
49- var source = document . createElement ( 'input' ) ;
5043 source . id = 'dep_source' ;
5144 source . value = '1' ;
5245 document . body . appendChild ( source ) ;
5346
54- // Initialize controller with dependency that evaluates to true (shouldShowUp = true)
47+ if ( window . Event ) {
48+ window . Event . observe = function ( ) { } ;
49+ }
5550 /* eslint-disable no-new */
5651 new window . FormElementDependenceController ( {
5752 'test_input_dependent' : {
@@ -68,6 +63,9 @@ define([
6863 expect ( normalInput . disabled ) . toBe ( false ) ;
6964
7065 // Cleanup
66+ if ( window . Event && originalObserve ) {
67+ window . Event . observe = originalObserve ;
68+ }
7169 document . body . removeChild ( container ) ;
7270 document . body . removeChild ( source ) ;
7371 } ) ;
0 commit comments