Skip to content

Commit

Permalink
Avoid calling AppRegistry.registerComponent in mocked mode (wix#7234)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd authored Aug 31, 2021
1 parent dfdb451 commit ec34501
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
5 changes: 5 additions & 0 deletions lib/src/Mock/mocks/AppRegistryService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ComponentProvider } from 'react-native';

export class AppRegistryService {
registerComponent(_appKey: string, _getComponentFunc: ComponentProvider) {}
}
7 changes: 4 additions & 3 deletions lib/src/Navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export class NavigationRoot {

constructor(
private readonly nativeCommandsSender: NativeCommandsSender,
private readonly nativeEventsReceiver: NativeEventsReceiver
private readonly nativeEventsReceiver: NativeEventsReceiver,
private readonly appRegistryService: AppRegistryService
) {
this.componentWrapper = new ComponentWrapper();
this.store = new Store();
Expand All @@ -59,12 +60,12 @@ export class NavigationRoot {
this.nativeEventsReceiver,
this.store
);
const appRegistryService = new AppRegistryService();

this.componentRegistry = new ComponentRegistry(
this.store,
this.componentEventsObserver,
this.componentWrapper,
appRegistryService
this.appRegistryService
);
this.layoutTreeParser = new LayoutTreeParser(this.uniqueIdProvider);
const optionsProcessor = new OptionsProcessor(
Expand Down
13 changes: 9 additions & 4 deletions lib/src/NavigationDelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,24 @@ import { OptionsProcessor as OptionProcessor } from './interfaces/Processors';
import { NavigationRoot } from './Navigation';
import { NativeCommandsSender } from './adapters/NativeCommandsSender';
import { NativeEventsReceiver } from './adapters/NativeEventsReceiver';
import { AppRegistryService } from './adapters/AppRegistryService';

export class NavigationDelegate {
private concreteNavigation: NavigationRoot;
constructor() {
this.concreteNavigation = this.createConcreteNavigation(
new NativeCommandsSender(),
new NativeEventsReceiver()
new NativeEventsReceiver(),
new AppRegistryService()
);
}

private createConcreteNavigation(
nativeCommandsSender: NativeCommandsSender,
nativeEventsReceiver: NativeEventsReceiver
nativeEventsReceiver: NativeEventsReceiver,
appRegistryService: AppRegistryService
) {
return new NavigationRoot(nativeCommandsSender, nativeEventsReceiver);
return new NavigationRoot(nativeCommandsSender, nativeEventsReceiver, appRegistryService);
}

/**
Expand Down Expand Up @@ -226,9 +229,11 @@ export class NavigationDelegate {
public mockNativeComponents() {
const { NativeCommandsSender } = require('./Mock/mocks/NativeCommandsSender');
const { NativeEventsReceiver } = require('./Mock/mocks/NativeEventsReceiver');
const { AppRegistryService } = require('./Mock/mocks/AppRegistryService');
this.concreteNavigation = this.createConcreteNavigation(
new NativeCommandsSender(),
new NativeEventsReceiver()
new NativeEventsReceiver(),
new AppRegistryService()
);
}

Expand Down

0 comments on commit ec34501

Please sign in to comment.