|
@@ -12,13 +12,13 @@ describe(`ComponentEventRegistry`, () => {
|
12
|
12
|
eventRegistry = {
|
13
|
13
|
componentDidAppear: jest.fn(),
|
14
|
14
|
componentDidDisappear: jest.fn(),
|
15
|
|
- onNavigationInteraction: jest.fn()
|
|
15
|
+ onNavigationButtonPressed: jest.fn()
|
16
|
16
|
};
|
17
|
17
|
|
18
|
18
|
mockComponentRef = {
|
19
|
19
|
componentDidAppear: jest.fn(),
|
20
|
20
|
componentDidDisappear: jest.fn(),
|
21
|
|
- onNavigationInteraction: jest.fn()
|
|
21
|
+ onNavigationButtonPressed: jest.fn()
|
22
|
22
|
};
|
23
|
23
|
|
24
|
24
|
store = new Store();
|
|
@@ -30,26 +30,26 @@ describe(`ComponentEventRegistry`, () => {
|
30
|
30
|
it('register for lifecycle events on eventRegistry', () => {
|
31
|
31
|
expect(eventRegistry.componentDidAppear).toHaveBeenCalledTimes(0);
|
32
|
32
|
expect(eventRegistry.componentDidDisappear).toHaveBeenCalledTimes(0);
|
33
|
|
- expect(eventRegistry.onNavigationInteraction).toHaveBeenCalledTimes(0);
|
|
33
|
+ expect(eventRegistry.onNavigationButtonPressed).toHaveBeenCalledTimes(0);
|
34
|
34
|
uut.registerForAllComponents();
|
35
|
35
|
expect(eventRegistry.componentDidAppear).toHaveBeenCalledTimes(1);
|
36
|
36
|
expect(eventRegistry.componentDidDisappear).toHaveBeenCalledTimes(1);
|
37
|
|
- expect(eventRegistry.onNavigationInteraction).toHaveBeenCalledTimes(1);
|
|
37
|
+ expect(eventRegistry.onNavigationButtonPressed).toHaveBeenCalledTimes(1);
|
38
|
38
|
});
|
39
|
39
|
|
40
|
40
|
it('bubbles lifecycle to component from store', () => {
|
41
|
41
|
const params = {};
|
42
|
42
|
expect(mockComponentRef.componentDidAppear).toHaveBeenCalledTimes(0);
|
43
|
43
|
expect(mockComponentRef.componentDidDisappear).toHaveBeenCalledTimes(0);
|
44
|
|
- expect(mockComponentRef.onNavigationInteraction).toHaveBeenCalledTimes(0);
|
|
44
|
+ expect(mockComponentRef.onNavigationButtonPressed).toHaveBeenCalledTimes(0);
|
45
|
45
|
uut.registerForAllComponents();
|
46
|
46
|
eventRegistry.componentDidAppear.mock.calls[0][0](refId);
|
47
|
47
|
eventRegistry.componentDidDisappear.mock.calls[0][0](refId);
|
48
|
|
- eventRegistry.onNavigationInteraction.mock.calls[0][0](refId, params);
|
|
48
|
+ eventRegistry.onNavigationButtonPressed.mock.calls[0][0](refId, params);
|
49
|
49
|
expect(mockComponentRef.componentDidAppear).toHaveBeenCalledTimes(1);
|
50
|
50
|
expect(mockComponentRef.componentDidDisappear).toHaveBeenCalledTimes(1);
|
51
|
|
- expect(mockComponentRef.onNavigationInteraction).toHaveBeenCalledTimes(1);
|
52
|
|
- expect(mockComponentRef.onNavigationInteraction).toHaveBeenCalledWith(params);
|
|
51
|
+ expect(mockComponentRef.onNavigationButtonPressed).toHaveBeenCalledTimes(1);
|
|
52
|
+ expect(mockComponentRef.onNavigationButtonPressed).toHaveBeenCalledWith(params);
|
53
|
53
|
});
|
54
|
54
|
|
55
|
55
|
it('defensive unknown id', () => {
|
|
@@ -57,7 +57,7 @@ describe(`ComponentEventRegistry`, () => {
|
57
|
57
|
expect(() => {
|
58
|
58
|
eventRegistry.componentDidAppear.mock.calls[0][0]('bad id');
|
59
|
59
|
eventRegistry.componentDidDisappear.mock.calls[0][0]('bad id');
|
60
|
|
- eventRegistry.onNavigationInteraction.mock.calls[0][0]('bad id', {});
|
|
60
|
+ eventRegistry.onNavigationButtonPressed.mock.calls[0][0]('bad id', {});
|
61
|
61
|
}).not.toThrow();
|
62
|
62
|
});
|
63
|
63
|
|
|
@@ -67,7 +67,7 @@ describe(`ComponentEventRegistry`, () => {
|
67
|
67
|
expect(() => {
|
68
|
68
|
eventRegistry.componentDidAppear.mock.calls[0][0]('myId');
|
69
|
69
|
eventRegistry.componentDidDisappear.mock.calls[0][0]('myId');
|
70
|
|
- eventRegistry.onNavigationInteraction.mock.calls[0][0]('myId', {});
|
|
70
|
+ eventRegistry.onNavigationButtonPressed.mock.calls[0][0]('myId', {});
|
71
|
71
|
}).not.toThrow();
|
72
|
72
|
});
|
73
|
73
|
});
|