Cmatch: Do not fail given __classes question
* src/client/Cmatch.js (handleClassMatch): Rename from _handleClassMatch. Make protected. Check for truthy `vis'. * test/client/CmatchTest.js: Update accordingly.master
parent
b5fc56c62c
commit
9ad8cb96b8
|
@ -150,7 +150,7 @@ module.exports = Class( 'Cmatch',
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_self._handleClassMatch( cmatch );
|
_self.handleClassMatch( cmatch );
|
||||||
cmatchprot = false;
|
cmatchprot = false;
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
@ -224,7 +224,7 @@ module.exports = Class( 'Cmatch',
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
'private _handleClassMatch': function( cmatch, force )
|
'virtual protected handleClassMatch': function( cmatch, force )
|
||||||
{
|
{
|
||||||
force = !!force;
|
force = !!force;
|
||||||
|
|
||||||
|
@ -268,6 +268,12 @@ module.exports = Class( 'Cmatch',
|
||||||
|| []
|
|| []
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// this should really only ever be the case for __classes
|
||||||
|
if ( !vis )
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Figure out something better here. This is currently
|
// TODO: Figure out something better here. This is currently
|
||||||
// needed for hiding statics---they are registered as exclusive
|
// needed for hiding statics---they are registered as exclusive
|
||||||
// fields (`fields', above), but aren't actually fields (they're
|
// fields (`fields', above), but aren't actually fields (they're
|
||||||
|
@ -494,7 +500,7 @@ module.exports = Class( 'Cmatch',
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._handleClassMatch( this._cmatch, true );
|
this.handleClassMatch( this._cmatch, true );
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
|
@ -25,13 +25,22 @@ const { expect } = require( 'chai' );
|
||||||
const Sut = require( '../../src/client/Cmatch' )
|
const Sut = require( '../../src/client/Cmatch' )
|
||||||
.extend(
|
.extend(
|
||||||
{
|
{
|
||||||
'override constructor'( _, __, ___ ) {},
|
'override constructor'( class_matcher, program, client )
|
||||||
|
{
|
||||||
|
this.__super( class_matcher || {}, program || {}, client || {} );
|
||||||
|
},
|
||||||
|
|
||||||
// make public
|
// make public
|
||||||
'override public markShowHide'( field, visq, show, hide )
|
'override public markShowHide'( field, visq, show, hide )
|
||||||
{
|
{
|
||||||
return this.__super( field, visq, show, hide );
|
return this.__super( field, visq, show, hide );
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// make public
|
||||||
|
'override public handleClassMatch'( cmatch, force )
|
||||||
|
{
|
||||||
|
this.__super( cmatch, force );
|
||||||
|
},
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,4 +93,38 @@ describe( "Cmatch", () =>
|
||||||
|
|
||||||
expect( visq.bar ).to.equal( barval );
|
expect( visq.bar ).to.equal( barval );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __classes is always returned (at least at the time of writing) by
|
||||||
|
* TAME. here was a bug when it was recognized as a field (e.g. marked
|
||||||
|
* as an `external' in program.xml),
|
||||||
|
*/
|
||||||
|
it( "does not fail when __classes is a known field", () =>
|
||||||
|
{
|
||||||
|
const cmatch = {
|
||||||
|
// populated by TAME, always
|
||||||
|
__classes: {},
|
||||||
|
};
|
||||||
|
|
||||||
|
const field_names = {
|
||||||
|
__classes: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const mock_client = {
|
||||||
|
getUi: () => ( {
|
||||||
|
setCmatch() {},
|
||||||
|
getCurrentStep: () => ( {
|
||||||
|
getStep: () => ( {
|
||||||
|
getExclusiveFieldNames: () => field_names,
|
||||||
|
} )
|
||||||
|
} )
|
||||||
|
} ),
|
||||||
|
getQuote: () => ( {} ),
|
||||||
|
};
|
||||||
|
|
||||||
|
Sut( {}, {}, mock_client ).handleClassMatch(
|
||||||
|
cmatch, false
|
||||||
|
);
|
||||||
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in New Issue