Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-04-16 15:30:19 -0400
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-04-16 15:30:19 -0400
commit9ad8cb96b851b4d2d8a6f40c2f39353cb93a93d0 (patch)
tree60543f33f04e76cbd0c98b19f9f86306e61321dc
parentb5fc56c62c8221363759a04dd4d70845d0e1bfd3 (diff)
downloadliza-9ad8cb96b851b4d2d8a6f40c2f39353cb93a93d0.tar.gz
liza-9ad8cb96b851b4d2d8a6f40c2f39353cb93a93d0.tar.bz2
liza-9ad8cb96b851b4d2d8a6f40c2f39353cb93a93d0.zip
Cmatch: Do not fail given __classes questionv3.5.4
* src/client/Cmatch.js (handleClassMatch): Rename from _handleClassMatch. Make protected. Check for truthy `vis'. * test/client/CmatchTest.js: Update accordingly.
-rw-r--r--src/client/Cmatch.js12
-rw-r--r--test/client/CmatchTest.js47
2 files changed, 54 insertions, 5 deletions
diff --git a/src/client/Cmatch.js b/src/client/Cmatch.js
index 4705e0c..2dc316c 100644
--- a/src/client/Cmatch.js
+++ b/src/client/Cmatch.js
@@ -150,7 +150,7 @@ module.exports = Class( 'Cmatch',
return;
}
- _self._handleClassMatch( cmatch );
+ _self.handleClassMatch( cmatch );
cmatchprot = false;
} );
} );
@@ -224,7 +224,7 @@ module.exports = Class( 'Cmatch',
},
- 'private _handleClassMatch': function( cmatch, force )
+ 'virtual protected handleClassMatch': function( cmatch, 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
// needed for hiding statics---they are registered as exclusive
// fields (`fields', above), but aren't actually fields (they're
@@ -494,7 +500,7 @@ module.exports = Class( 'Cmatch',
return this;
}
- this._handleClassMatch( this._cmatch, true );
+ this.handleClassMatch( this._cmatch, true );
return this;
},
diff --git a/test/client/CmatchTest.js b/test/client/CmatchTest.js
index cfbfb14..10fdd39 100644
--- a/test/client/CmatchTest.js
+++ b/test/client/CmatchTest.js
@@ -25,13 +25,22 @@ const { expect } = require( 'chai' );
const Sut = require( '../../src/client/Cmatch' )
.extend(
{
- 'override constructor'( _, __, ___ ) {},
+ 'override constructor'( class_matcher, program, client )
+ {
+ this.__super( class_matcher || {}, program || {}, client || {} );
+ },
// make public
'override public markShowHide'( 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 );
} );
+
+
+ /**
+ * __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
+ );
+ } );
} );