Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib/dist/Mock';
4 changes: 2 additions & 2 deletions jest-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const { mockDetox } = require('detox-testing-library-rnn-adapter');
mockDetox(() => require('./playground/index'));

beforeEach(() => {
const { Navigation } = require('react-native-navigation');
const { mockNativeComponents } = require('react-native-navigation/Mock');
setTimeout = (func) => {
func();
};
Navigation.mockNativeComponents();
mockNativeComponents();
mockUILib();
});

Expand Down
13 changes: 13 additions & 0 deletions lib/src/Mock/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
export const ApplicationMock = require('./Application').Application;

export * from './constants';

export function mockNativeComponents() {
const { NativeCommandsSender } = require('./mocks/NativeCommandsSender');
const { NativeEventsReceiver } = require('./mocks/NativeEventsReceiver');
const { AppRegistryService } = require('./mocks/AppRegistryService');
const { Navigation } = require('react-native-navigation');

Navigation.mockNativeComponents(
new NativeCommandsSender(),
new NativeEventsReceiver(),
new AppRegistryService()
);
}
15 changes: 8 additions & 7 deletions lib/src/NavigationDelegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,15 @@ export class NavigationDelegate {
return this.concreteNavigation.TouchablePreview;
}

public mockNativeComponents() {
const { NativeCommandsSender } = require('./Mock/mocks/NativeCommandsSender');
const { NativeEventsReceiver } = require('./Mock/mocks/NativeEventsReceiver');
const { AppRegistryService } = require('./Mock/mocks/AppRegistryService');
public mockNativeComponents(
mockedNativeCommandsSender: NativeCommandsSender,
mockedNativeEventsReceiver: NativeEventsReceiver,
mockedAppRegistryService: AppRegistryService
) {
this.concreteNavigation = this.createConcreteNavigation(
new NativeCommandsSender(),
new NativeEventsReceiver(),
new AppRegistryService()
mockedNativeCommandsSender,
mockedNativeEventsReceiver,
mockedAppRegistryService
);
}

Expand Down
1 change: 0 additions & 1 deletion lib/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ export * from './interfaces/NavigationFunctionComponent';
export * from './interfaces/CommandName';
export * from './interfaces/Processors';
export * from './interfaces/ProcessorSubscription';
export * from './Mock';
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
"ts-mockito": "^2.3.1",
"typedoc": "0.x.x",
"typescript": "3.9.5",
"detox-testing-library-rnn-adapter": "1.x.x",
"remx": "4.x.x"
"detox-testing-library-rnn-adapter": "2.x.x",
"remx": "3.x.x"
},
"jest": {
"preset": "react-native",
Expand All @@ -134,6 +134,7 @@
"./jest-setup.js"
],
"moduleNameMapper": {
"react-native-navigation/Mock": "<rootDir>/lib/src/Mock",
"react-native-navigation": "<rootDir>/lib/src",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/playground/img/layouts@2x.png"
},
Expand Down Expand Up @@ -257,4 +258,4 @@
}
}
}
}
}