From f104162937dc5003daf5f58f073b0a6e2ce69cc3 Mon Sep 17 00:00:00 2001 From: Sam Reid Date: Tue, 20 Sep 2022 19:18:33 -0600 Subject: [PATCH] Add API validation for preferences phetioState, see https://github.com/phetsims/joist/issues/744 --- js/phetioAPIValidation.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/phetioAPIValidation.ts b/js/phetioAPIValidation.ts index 2e645057..e976474f 100644 --- a/js/phetioAPIValidation.ts +++ b/js/phetioAPIValidation.ts @@ -109,8 +109,13 @@ class PhetioAPIValidation { } assert && assert( !phetioObject.phetioReadOnly, 'preferences model and its descendants should be phetioReadOnly: false, key=' + preferencesKey ); - // Audio manager, color profile property and localeProperty are supposed to be stateful. - // assert && assert( !phetioObject.phetioState, 'preferences model and its descendants should be phetioState: false, key=' + preferencesKey ); + // Audio manager, color profile property and localeProperty are supposed to be stateful. All other preferences + // should be phetioState: false so they are not captured in the state + assert && assert( phetioObject.phetioState === + ( phetioObject.phetioID.endsWith( '.colorProfileProperty' ) || + phetioObject.phetioID.endsWith( '.audioEnabledProperty' ) || + phetioObject.phetioID.endsWith( '.localeProperty' ) ), + 'most preferences should be phetioState: false, key=' + preferencesKey ); } ); }