|
@@ -5,7 +5,7 @@ import { NativeEventsReceiver } from '../adapters/NativeEventsReceiver.mock';
|
5
|
5
|
|
6
|
6
|
describe('ComponentEventsObserver', () => {
|
7
|
7
|
const mockEventsReceiver = new NativeEventsReceiver();
|
8
|
|
- const uut = new ComponentEventsObserver(mockEventsReceiver);
|
|
8
|
+ let uut;
|
9
|
9
|
const didAppearFn = jest.fn();
|
10
|
10
|
const didDisappearFn = jest.fn();
|
11
|
11
|
const didMountFn = jest.fn();
|
|
@@ -65,6 +65,10 @@ describe('ComponentEventsObserver', () => {
|
65
|
65
|
}
|
66
|
66
|
}
|
67
|
67
|
|
|
68
|
+ beforeEach(() => {
|
|
69
|
+ uut = new ComponentEventsObserver(mockEventsReceiver);
|
|
70
|
+ });
|
|
71
|
+
|
68
|
72
|
it(`bindComponent expects a component with componentId`, () => {
|
69
|
73
|
const tree = renderer.create(<SimpleScreen />);
|
70
|
74
|
expect(() => uut.bindComponent(tree.getInstance() as any)).toThrow('');
|
|
@@ -187,4 +191,29 @@ describe('ComponentEventsObserver', () => {
|
187
|
191
|
expect(mockEventsReceiver.registerSearchBarUpdatedListener).toHaveBeenCalledTimes(1);
|
188
|
192
|
expect(mockEventsReceiver.registerSearchBarCancelPressedListener).toHaveBeenCalledTimes(1);
|
189
|
193
|
});
|
|
194
|
+
|
|
195
|
+ it(`warn when button event is not getting handled`, () => {
|
|
196
|
+ const tree1 = renderer.create(<SimpleScreen componentId={'myCompId'} />);
|
|
197
|
+ const instance1 = tree1.getInstance() as any;
|
|
198
|
+ console.warn = jest.fn();
|
|
199
|
+ uut.bindComponent(instance1);
|
|
200
|
+
|
|
201
|
+ uut.notifyNavigationButtonPressed({ componentId: 'myCompId', buttonId: 'myButtonId' });
|
|
202
|
+
|
|
203
|
+ expect(console.warn).toHaveBeenCalledTimes(1);
|
|
204
|
+ expect(console.warn).toHaveBeenCalledWith(`navigationButtonPressed for button 'myButtonId' was not handled`);
|
|
205
|
+ });
|
|
206
|
+
|
|
207
|
+ it(`doesn't warn when button event is getting handled`, () => {
|
|
208
|
+ const tree1 = renderer.create(<SimpleScreen componentId={'myCompId'} />);
|
|
209
|
+ const instance1 = tree1.getInstance() as any;
|
|
210
|
+ console.warn = jest.fn();
|
|
211
|
+
|
|
212
|
+ instance1.navigationButtonPressed = jest.fn();
|
|
213
|
+ uut.bindComponent(instance1);
|
|
214
|
+
|
|
215
|
+ uut.notifyNavigationButtonPressed({ componentId: 'myCompId', buttonId: 'myButtonId' });
|
|
216
|
+
|
|
217
|
+ expect(console.warn).toHaveBeenCalledTimes(0);
|
|
218
|
+ });
|
190
|
219
|
});
|