@@ -3,6 +3,8 @@ describe('Check', function() {
33
44 var Check = axe . _thisWillBeDeletedDoNotUse . base . Check ;
55 var CheckResult = axe . _thisWillBeDeletedDoNotUse . base . CheckResult ;
6+ var metadataFunctionMap =
7+ axe . _thisWillBeDeletedDoNotUse . base . metadataFunctionMap ;
68 var noop = function ( ) { } ;
79
810 var fixture = document . getElementById ( 'fixture' ) ;
@@ -99,8 +101,7 @@ describe('Check', function() {
99101 delete Check . prototype . test ;
100102 } ) ;
101103 it ( 'should override evaluate as ID' , function ( ) {
102- axe . _load ( { } ) ;
103- axe . _audit . metadataFunctionMap [ 'custom-evaluate' ] = function ( ) {
104+ metadataFunctionMap [ 'custom-evaluate' ] = function ( ) {
104105 return 'fong' ;
105106 } ;
106107
@@ -113,11 +114,10 @@ describe('Check', function() {
113114 check . configure ( { evaluate : 'custom-evaluate' } ) ;
114115 assert . equal ( 'fong' , check . test ( ) ) ;
115116 delete Check . prototype . test ;
116- delete axe . _audit . metadataFunctionMap [ 'custom-evaluate' ] ;
117+ delete metadataFunctionMap [ 'custom-evaluate' ] ;
117118 } ) ;
118119 it ( 'should override after as ID' , function ( ) {
119- axe . _load ( { } ) ;
120- axe . _audit . metadataFunctionMap [ 'custom-after' ] = function ( ) {
120+ metadataFunctionMap [ 'custom-after' ] = function ( ) {
121121 return 'fong' ;
122122 } ;
123123
@@ -130,7 +130,7 @@ describe('Check', function() {
130130 check . configure ( { after : 'custom-after' } ) ;
131131 assert . equal ( 'fong' , check . test ( ) ) ;
132132 delete Check . prototype . test ;
133- delete axe . _audit . metadataFunctionMap [ 'custom-after' ] ;
133+ delete metadataFunctionMap [ 'custom-after' ] ;
134134 } ) ;
135135 it ( 'should error if evaluate does not match an ID' , function ( ) {
136136 function fn ( ) {
@@ -226,10 +226,21 @@ describe('Check', function() {
226226 } ) . run ( fixture , { options : expected } , { } , noop ) ;
227227 } ) ;
228228
229- it ( 'should normalize non-object options' , function ( done ) {
229+ it ( 'should normalize non-object options for internal checks' , function ( done ) {
230+ metadataFunctionMap [ 'custom-check' ] = function ( node , options ) {
231+ assert . deepEqual ( options , { value : 'foo' } ) ;
232+ done ( ) ;
233+ } ;
234+ new Check ( {
235+ evaluate : 'custom-check'
236+ } ) . run ( fixture , { options : 'foo' } , { } , noop ) ;
237+ delete metadataFunctionMap [ 'custom-check' ] ;
238+ } ) ;
239+
240+ it ( 'should not normalize non-object options for external checks' , function ( done ) {
230241 new Check ( {
231242 evaluate : function ( node , options ) {
232- assert . deepEqual ( options , { value : 'foo' } ) ;
243+ assert . deepEqual ( options , 'foo' ) ;
233244 done ( ) ;
234245 }
235246 } ) . run ( fixture , { options : 'foo' } , { } , noop ) ;
@@ -388,13 +399,24 @@ describe('Check', function() {
388399 } ) . runSync ( fixture , { options : expected } , { } ) ;
389400 } ) ;
390401
391- it ( 'should normalize non-object options' , function ( done ) {
402+ it ( 'should normalize non-object options for internal checks' , function ( done ) {
403+ metadataFunctionMap [ 'custom-check' ] = function ( node , options ) {
404+ assert . deepEqual ( options , { value : 'foo' } ) ;
405+ done ( ) ;
406+ } ;
407+ new Check ( {
408+ evaluate : 'custom-check'
409+ } ) . runSync ( fixture , { options : 'foo' } , { } ) ;
410+ delete metadataFunctionMap [ 'custom-check' ] ;
411+ } ) ;
412+
413+ it ( 'should not normalize non-object options for external checks' , function ( done ) {
392414 new Check ( {
393415 evaluate : function ( node , options ) {
394- assert . deepEqual ( options , { value : 'foo' } ) ;
416+ assert . deepEqual ( options , 'foo' ) ;
395417 done ( ) ;
396418 }
397- } ) . run ( fixture , { options : 'foo' } , { } , noop ) ;
419+ } ) . runSync ( fixture , { options : 'foo' } , { } ) ;
398420 } ) ;
399421
400422 it ( 'should pass the context through to check evaluate call' , function ( ) {
@@ -569,12 +591,20 @@ describe('Check', function() {
569591 assert . equal ( new Check ( spec ) . options , spec . options ) ;
570592 } ) ;
571593
572- it ( 'should normalize non-object options' , function ( ) {
594+ it ( 'should normalize non-object options for internal checks ' , function ( ) {
573595 var spec = {
574596 options : 'foo'
575597 } ;
576598 assert . deepEqual ( new Check ( spec ) . options , { value : 'foo' } ) ;
577599 } ) ;
600+
601+ it ( 'should not normalize non-object options for external checks' , function ( ) {
602+ var spec = {
603+ options : 'foo' ,
604+ evaluate : function ( ) { }
605+ } ;
606+ assert . deepEqual ( new Check ( spec ) . options , 'foo' ) ;
607+ } ) ;
578608 } ) ;
579609
580610 describe ( '.evaluate' , function ( ) {
0 commit comments