@@ -46,15 +46,28 @@ export class ContextProviderRegistryContainer {
4646 * };
4747 *
4848 */
49- export const extendAndPatchRegistry = ( registryContainer , classConfigMap , classesToPatch = { } ) => {
49+ export const extendAndPatchRegistry = (
50+ registryContainer ,
51+ classConfigMap ,
52+ classesToPatch = { } ,
53+ defaultSettings = { } ,
54+ ) => {
5055 Object . entries ( classConfigMap ) . forEach ( ( [ name , { providerCls, config } ] ) => {
5156 Object . entries ( classesToPatch ) . forEach ( ( [ clsName , cls ] ) => {
5257 if ( providerCls [ clsName ] ) {
5358 providerCls [ clsName ] = cls ;
5459 }
5560 } ) ;
61+ // Override defaults for this particular context provider
62+ const providerSpecificDefaults = defaultSettings [ name ] || { } ;
63+
64+ const combinedConfig = {
65+ ...config ,
66+ ...providerSpecificDefaults ,
67+ } ;
68+
5669 registryContainer . addProvider ( {
57- instance : providerCls . getConstructorConfig ( config ) ,
70+ instance : providerCls . getConstructorConfig ( combinedConfig ) ,
5871 name,
5972 } ) ;
6073 } ) ;
@@ -66,7 +79,16 @@ export const extendAndPatchRegistry = (registryContainer, classConfigMap, classe
6679 * @param {Object } classConfigMap
6780 * @param {{Material: SpecificMockMaterial} } classesToPatch
6881 */
69- export const createAndPatchRegistry = ( classConfigMap , classesToPatch = { } ) => {
82+ export const createAndPatchRegistry = (
83+ classConfigMap ,
84+ classesToPatch = { } ,
85+ defaultSettings = { } ,
86+ ) => {
7087 const registryContainer = new ContextProviderRegistryContainer ( ) ;
71- return extendAndPatchRegistry ( registryContainer , classConfigMap , classesToPatch ) ;
88+ return extendAndPatchRegistry (
89+ registryContainer ,
90+ classConfigMap ,
91+ classesToPatch ,
92+ defaultSettings ,
93+ ) ;
7294} ;
0 commit comments