diff --git a/lib/src/commands/Commands.test.ts b/lib/src/commands/Commands.test.ts index 0c7a6328f23..3f8c3febea7 100644 --- a/lib/src/commands/Commands.test.ts +++ b/lib/src/commands/Commands.test.ts @@ -226,6 +226,46 @@ describe('Commands', () => { `Navigation.mergeOptions was invoked on component with id: ${componentId} before it is mounted, this can cause UI issues and should be avoided.\n Use static options instead.` ); }); + + it('processes mergeOptions', async () => { + const options = { + animations: { + dismissModal: { + enabled: false, + }, + }, + }; + + uut.mergeOptions('myUniqueId', options); + verify( + mockedOptionsProcessor.processOptions( + CommandName.MergeOptions, + deepEqual(options), + undefined + ) + ).called(); + }); + + it('processing mergeOptions should pass component props', async () => { + const options = { + animations: { + dismissModal: { + enabled: false, + }, + }, + }; + const passProps = { prop: '1' }; + + when(mockedStore.getPropsForId('myUniqueId')).thenReturn(passProps); + uut.mergeOptions('myUniqueId', options); + verify( + mockedOptionsProcessor.processOptions( + CommandName.MergeOptions, + deepEqual(options), + passProps + ) + ).called(); + }); }); describe('updateProps', () => { diff --git a/lib/src/commands/Commands.ts b/lib/src/commands/Commands.ts index cca3e2b697f..af2427af15e 100644 --- a/lib/src/commands/Commands.ts +++ b/lib/src/commands/Commands.ts @@ -73,9 +73,10 @@ export class Commands { public mergeOptions(componentId: string, options: Options) { const input = cloneDeep(options); - this.optionsProcessor.processOptions(CommandName.MergeOptions, input); const component = this.store.getComponentInstance(componentId); + const componentProps = this.store.getPropsForId(componentId) || undefined; + this.optionsProcessor.processOptions(CommandName.MergeOptions, input, componentProps); if (component && !component.isMounted) console.warn( `Navigation.mergeOptions was invoked on component with id: ${componentId} before it is mounted, this can cause UI issues and should be avoided.\n Use static options instead.`