@@ -165,6 +165,15 @@ describe('DigitalHumanEngine', () => {
165165 expect ( handler ) . toHaveBeenCalledWith ( { type : 'expression:change' , value : 'smile' } ) ;
166166 } ) ;
167167
168+ it ( 'emits normalized expression:change event for invalid expressions' , ( ) => {
169+ const handler = vi . fn ( ) ;
170+ engine . on ( 'expression:change' , handler ) ;
171+
172+ engine . setExpression ( 'invalid_expr' ) ;
173+
174+ expect ( handler ) . toHaveBeenCalledWith ( { type : 'expression:change' , value : 'neutral' } ) ;
175+ } ) ;
176+
168177 it ( 'emits emotion:change event' , ( ) => {
169178 const handler = vi . fn ( ) ;
170179 engine . on ( 'emotion:change' , handler ) ;
@@ -173,6 +182,15 @@ describe('DigitalHumanEngine', () => {
173182 expect ( handler ) . toHaveBeenCalledWith ( { type : 'emotion:change' , value : 'happy' } ) ;
174183 } ) ;
175184
185+ it ( 'emits normalized emotion:change event for invalid emotions' , ( ) => {
186+ const handler = vi . fn ( ) ;
187+ engine . on ( 'emotion:change' , handler ) ;
188+
189+ engine . setEmotion ( 'confused' ) ;
190+
191+ expect ( handler ) . toHaveBeenCalledWith ( { type : 'emotion:change' , value : 'neutral' } ) ;
192+ } ) ;
193+
176194 it ( 'emits behavior:change event' , ( ) => {
177195 const handler = vi . fn ( ) ;
178196 engine . on ( 'behavior:change' , handler ) ;
@@ -181,6 +199,15 @@ describe('DigitalHumanEngine', () => {
181199 expect ( handler ) . toHaveBeenCalledWith ( { type : 'behavior:change' , value : 'thinking' } ) ;
182200 } ) ;
183201
202+ it ( 'emits normalized behavior:change event for invalid behaviors' , ( ) => {
203+ const handler = vi . fn ( ) ;
204+ engine . on ( 'behavior:change' , handler ) ;
205+
206+ engine . setBehavior ( 'flying' ) ;
207+
208+ expect ( handler ) . toHaveBeenCalledWith ( { type : 'behavior:change' , value : 'idle' } ) ;
209+ } ) ;
210+
184211 it ( 'emits animation:start and animation:end events' , ( ) => {
185212 vi . useFakeTimers ( ) ;
186213 const startHandler = vi . fn ( ) ;
0 commit comments