|
@@ -143,54 +143,54 @@ describe('ComponentWrapper', () => {
|
143
|
143
|
});
|
144
|
144
|
|
145
|
145
|
describe('component lifecycle', () => {
|
146
|
|
- const didAppearCallback = jest.fn();
|
147
|
|
- const didDisappearCallback = jest.fn();
|
148
|
|
- const onNavigationButtonPressedCallback = jest.fn();
|
|
146
|
+ const componentDidAppearCallback = jest.fn();
|
|
147
|
+ const componentDidDisappearCallback = jest.fn();
|
|
148
|
+ const onNavigationInteractionCallback = jest.fn();
|
149
|
149
|
|
150
|
150
|
class MyLifecycleComponent extends MyComponent {
|
151
|
|
- didAppear() {
|
152
|
|
- didAppearCallback();
|
|
151
|
+ componentDidAppear() {
|
|
152
|
+ componentDidAppearCallback();
|
153
|
153
|
}
|
154
|
154
|
|
155
|
|
- didDisappear() {
|
156
|
|
- didDisappearCallback();
|
|
155
|
+ componentDidDisappear() {
|
|
156
|
+ componentDidDisappearCallback();
|
157
|
157
|
}
|
158
|
158
|
|
159
|
|
- onNavigationButtonPressed() {
|
160
|
|
- onNavigationButtonPressedCallback();
|
|
159
|
+ onNavigationInteraction() {
|
|
160
|
+ onNavigationInteractionCallback();
|
161
|
161
|
}
|
162
|
162
|
}
|
163
|
163
|
|
164
|
|
- it('didAppear, didDisappear and onNavigationButtonPressed are optional', () => {
|
|
164
|
+ it('componentDidAppear, componentDidDisappear and onNavigationInteraction are optional', () => {
|
165
|
165
|
const NavigationComponent = ComponentWrapper.wrap(componentName, MyComponent, store);
|
166
|
166
|
const tree = renderer.create(<NavigationComponent componentId={'component1'} />);
|
167
|
|
- expect(() => tree.getInstance()!.didAppear()).not.toThrow();
|
168
|
|
- expect(() => tree.getInstance()!.didDisappear()).not.toThrow();
|
169
|
|
- expect(() => tree.getInstance()!.onNavigationButtonPressed()).not.toThrow();
|
|
167
|
+ expect(() => tree.getInstance()!.componentDidAppear()).not.toThrow();
|
|
168
|
+ expect(() => tree.getInstance()!.componentDidDisappear()).not.toThrow();
|
|
169
|
+ expect(() => tree.getInstance()!.onNavigationInteraction()).not.toThrow();
|
170
|
170
|
});
|
171
|
171
|
|
172
|
|
- it('calls didAppear on OriginalComponent', () => {
|
|
172
|
+ it('calls componentDidAppear on OriginalComponent', () => {
|
173
|
173
|
const NavigationComponent = ComponentWrapper.wrap(componentName, MyLifecycleComponent, store);
|
174
|
174
|
const tree = renderer.create(<NavigationComponent componentId={'component1'} />);
|
175
|
|
- expect(didAppearCallback).toHaveBeenCalledTimes(0);
|
176
|
|
- tree.getInstance()!.didAppear();
|
177
|
|
- expect(didAppearCallback).toHaveBeenCalledTimes(1);
|
|
175
|
+ expect(componentDidAppearCallback).toHaveBeenCalledTimes(0);
|
|
176
|
+ tree.getInstance()!.componentDidAppear();
|
|
177
|
+ expect(componentDidAppearCallback).toHaveBeenCalledTimes(1);
|
178
|
178
|
});
|
179
|
179
|
|
180
|
|
- it('calls didDisappear on OriginalComponent', () => {
|
|
180
|
+ it('calls componentDidDisappear on OriginalComponent', () => {
|
181
|
181
|
const NavigationComponent = ComponentWrapper.wrap(componentName, MyLifecycleComponent, store);
|
182
|
182
|
const tree = renderer.create(<NavigationComponent componentId={'component1'} />);
|
183
|
|
- expect(didDisappearCallback).toHaveBeenCalledTimes(0);
|
184
|
|
- tree.getInstance()!.didDisappear();
|
185
|
|
- expect(didDisappearCallback).toHaveBeenCalledTimes(1);
|
|
183
|
+ expect(componentDidDisappearCallback).toHaveBeenCalledTimes(0);
|
|
184
|
+ tree.getInstance()!.componentDidDisappear();
|
|
185
|
+ expect(componentDidDisappearCallback).toHaveBeenCalledTimes(1);
|
186
|
186
|
});
|
187
|
187
|
|
188
|
|
- it('calls onNavigationButtonPressed on OriginalComponent', () => {
|
|
188
|
+ it('calls onNavigationInteraction on OriginalComponent', () => {
|
189
|
189
|
const NavigationComponent = ComponentWrapper.wrap(componentName, MyLifecycleComponent, store);
|
190
|
190
|
const tree = renderer.create(<NavigationComponent componentId={'component1'} />);
|
191
|
|
- expect(onNavigationButtonPressedCallback).toHaveBeenCalledTimes(0);
|
192
|
|
- tree.getInstance()!.onNavigationButtonPressed();
|
193
|
|
- expect(onNavigationButtonPressedCallback).toHaveBeenCalledTimes(1);
|
|
191
|
+ expect(onNavigationInteractionCallback).toHaveBeenCalledTimes(0);
|
|
192
|
+ tree.getInstance()!.onNavigationInteraction();
|
|
193
|
+ expect(onNavigationInteractionCallback).toHaveBeenCalledTimes(1);
|
194
|
194
|
});
|
195
|
195
|
});
|
196
|
196
|
});
|