|
@@ -19,7 +19,8 @@ describe(`ComponentEventsObserver`, () => {
|
19
|
19
|
componentDidAppear: jest.fn(),
|
20
|
20
|
componentDidDisappear: jest.fn(),
|
21
|
21
|
onNavigationButtonPressed: jest.fn(),
|
22
|
|
- onSearchBarUpdated: jest.fn()
|
|
22
|
+ onSearchBarUpdated: jest.fn(),
|
|
23
|
+ onSearchBarCancelPressed: jest.fn()
|
23
|
24
|
};
|
24
|
25
|
|
25
|
26
|
store = new Store();
|
|
@@ -44,6 +45,7 @@ describe(`ComponentEventsObserver`, () => {
|
44
|
45
|
expect(mockComponentRef.componentDidDisappear).toHaveBeenCalledTimes(0);
|
45
|
46
|
expect(mockComponentRef.onNavigationButtonPressed).toHaveBeenCalledTimes(0);
|
46
|
47
|
expect(mockComponentRef.onSearchBarUpdated).toHaveBeenCalledTimes(0);
|
|
48
|
+ expect(mockComponentRef.onSearchBarCancelPressed).toHaveBeenCalledTimes(0);
|
47
|
49
|
uut.registerForAllComponents();
|
48
|
50
|
eventRegistry.registerComponentDidAppearListener.mock.calls[0][0](refId);
|
49
|
51
|
eventRegistry.registerComponentDidDisappearListener.mock.calls[0][0](refId);
|
|
@@ -52,6 +54,7 @@ describe(`ComponentEventsObserver`, () => {
|
52
|
54
|
expect(mockComponentRef.componentDidDisappear).toHaveBeenCalledTimes(1);
|
53
|
55
|
expect(mockComponentRef.onNavigationButtonPressed).toHaveBeenCalledTimes(0);
|
54
|
56
|
expect(mockComponentRef.onSearchBarUpdated).toHaveBeenCalledTimes(0);
|
|
57
|
+ expect(mockComponentRef.onSearchBarCancelPressed).toHaveBeenCalledTimes(0);
|
55
|
58
|
});
|
56
|
59
|
|
57
|
60
|
it('bubbles onNavigationButtonPressed to component by id', () => {
|
|
@@ -95,6 +98,26 @@ describe(`ComponentEventsObserver`, () => {
|
95
|
98
|
expect(mockComponentRef.onSearchBarUpdated).toHaveBeenCalledWith('query', true);
|
96
|
99
|
});
|
97
|
100
|
|
|
101
|
+ it('bubbles onSearchBarCancelPressed to component by id', () => {
|
|
102
|
+ const params = {
|
|
103
|
+ componentId: refId,
|
|
104
|
+ };
|
|
105
|
+ expect(mockComponentRef.onSearchBarCancelPressed).toHaveBeenCalledTimes(0);
|
|
106
|
+ uut.registerForAllComponents();
|
|
107
|
+
|
|
108
|
+ eventRegistry.registerNativeEventListener.mock.calls[0][0]('buttonPressed', params);
|
|
109
|
+ expect(mockComponentRef.onSearchBarCancelPressed).toHaveBeenCalledTimes(0);
|
|
110
|
+
|
|
111
|
+ eventRegistry.registerNativeEventListener.mock.calls[0][0]('searchBarCancelPressed', params);
|
|
112
|
+ expect(mockComponentRef.onSearchBarCancelPressed).toHaveBeenCalledTimes(1);
|
|
113
|
+
|
|
114
|
+ const paramsForUnexisted = {
|
|
115
|
+ componentId: 'NOT_EXISTED',
|
|
116
|
+ };
|
|
117
|
+ eventRegistry.registerNativeEventListener.mock.calls[0][0]('searchBarCancelPressed', paramsForUnexisted);
|
|
118
|
+ expect(mockComponentRef.onSearchBarCancelPressed).toHaveBeenCalledTimes(1);
|
|
119
|
+ });
|
|
120
|
+
|
98
|
121
|
it('defensive unknown id', () => {
|
99
|
122
|
uut.registerForAllComponents();
|
100
|
123
|
expect(() => {
|