Skip to content

Commit

Permalink
Assert that PhET-iO instrumented ProfileColorProperty instances have …
Browse files Browse the repository at this point in the history
…a tandem ending in ColorProperty, see #1251
  • Loading branch information
samreid committed Jul 28, 2021
1 parent d3b475a commit 5caade9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/util/ProfileColorProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
* @author Sam Reid (PhET Interactive Simulations)
*/
import arrayRemove from '../../../phet-core/js/arrayRemove.js';
import merge from '../../../phet-core/js/merge.js';
import Tandem from '../../../tandem/js/Tandem.js';
import scenery from '../scenery.js';
import SceneryConstants from '../SceneryConstants.js';
import Color from '../util/Color.js';
Expand All @@ -24,6 +26,10 @@ class ProfileColorProperty extends ColorProperty {
*/
constructor( name, colorProfileMap, options ) {

options = merge( {
tandem: Tandem.OPTIONAL
}, options );

assert && assert( !!name, 'ProfileColorProperty.options.name is required' );

// All values are eagerly coerced to Color instances for efficiency (so it only has to be done once) and simplicity
Expand All @@ -33,6 +39,11 @@ class ProfileColorProperty extends ColorProperty {
// Fallback to default if a color was not supplied.
super( colorProfileMap[ colorProfileProperty.value ] || colorProfileMap[ SceneryConstants.DEFAULT_COLOR_PROFILE ], options );

assert && assert( !this.isPhetioInstrumented() ||
options.tandem.name.endsWith( 'ColorProperty' ) ||
options.tandem.name === 'colorProperty',
`Property tandem.name must end with ColorProperty: ${options.tandem.phetioID}` );

// @public (ProfileColorProperty.js) - values are mutated by the HTML color wrapper.
this.colorProfileMap = colorProfileMap;

Expand Down

0 comments on commit 5caade9

Please sign in to comment.