|
@@ -82,4 +82,26 @@ describe('EventsRegistry', () => {
|
82
|
82
|
commandsObserver.notify('theCommandName', { x: 1 });
|
83
|
83
|
expect(cb).not.toHaveBeenCalled();
|
84
|
84
|
});
|
|
85
|
+
|
|
86
|
+ it('onNavigationEvent', () => {
|
|
87
|
+ const subscription = {};
|
|
88
|
+ const cb = jest.fn();
|
|
89
|
+ mockNativeEventsReceiver.registerOnNavigationEvent.mockReturnValueOnce(subscription);
|
|
90
|
+
|
|
91
|
+ const result = uut.onNavigationEvent(cb);
|
|
92
|
+
|
|
93
|
+ expect(result).toBe(subscription);
|
|
94
|
+ expect(mockNativeEventsReceiver.registerOnNavigationEvent).toHaveBeenCalledTimes(1);
|
|
95
|
+
|
|
96
|
+ mockNativeEventsReceiver.registerOnNavigationEvent.mock.calls[0][0]({ name: 'the event name', params: { a: 1 } });
|
|
97
|
+ expect(cb).toHaveBeenCalledWith('the event name', { a: 1 });
|
|
98
|
+ });
|
|
99
|
+
|
|
100
|
+ it('onNavigationEvent unregister', () => {
|
|
101
|
+ const subscription = {};
|
|
102
|
+ const cb = jest.fn();
|
|
103
|
+ mockNativeEventsReceiver.registerOnNavigationEvent.mockReturnValueOnce(subscription);
|
|
104
|
+ const result = uut.onNavigationEvent(cb);
|
|
105
|
+ expect(result).toBe(subscription);
|
|
106
|
+ });
|
85
|
107
|
});
|