|
|
@@ -1,111 +0,0 @@
|
|
1
|
|
-describe('Navigation', () => {
|
|
2
|
|
- let Navigation;
|
|
3
|
|
-
|
|
4
|
|
- beforeEach(() => {
|
|
5
|
|
- //TODO don't mock here, just create the actual object and assert on basic behavior
|
|
6
|
|
- jest.mock('./adapters/UniqueIdProvider');
|
|
7
|
|
- jest.mock('./adapters/NativeCommandsSender');
|
|
8
|
|
- jest.mock('./adapters/NativeEventsReceiver');
|
|
9
|
|
-
|
|
10
|
|
- jest.mock('./containers/ContainerRegistry');
|
|
11
|
|
- jest.mock('./commands/Commands');
|
|
12
|
|
-
|
|
13
|
|
- Navigation = require('./Navigation').default;
|
|
14
|
|
- });
|
|
15
|
|
-
|
|
16
|
|
- it('registerContainer delegates to ContainerRegistry', () => {
|
|
17
|
|
- expect(Navigation.containerRegistry.registerContainer).not.toHaveBeenCalled();
|
|
18
|
|
- const fn = jest.fn();
|
|
19
|
|
- Navigation.registerContainer('name', fn);
|
|
20
|
|
- expect(Navigation.containerRegistry.registerContainer).toHaveBeenCalledTimes(1);
|
|
21
|
|
- expect(Navigation.containerRegistry.registerContainer).toHaveBeenCalledWith('name', fn);
|
|
22
|
|
- });
|
|
23
|
|
-
|
|
24
|
|
- it('setRoot delegates to Commands', async () => {
|
|
25
|
|
- Navigation.commands.setRoot.mockReturnValue(Promise.resolve('result'));
|
|
26
|
|
- const params = {};
|
|
27
|
|
- const result = await Navigation.setRoot(params);
|
|
28
|
|
- expect(result).toEqual('result');
|
|
29
|
|
- expect(Navigation.commands.setRoot).toHaveBeenCalledTimes(1);
|
|
30
|
|
- expect(Navigation.commands.setRoot).toHaveBeenCalledWith(params);
|
|
31
|
|
- });
|
|
32
|
|
-
|
|
33
|
|
- it('setOptions delegates to Commands', async () => {
|
|
34
|
|
- const theContainerId = "7";
|
|
35
|
|
- const params = { title: "T" };
|
|
36
|
|
- Navigation.setOptions(theContainerId, params);
|
|
37
|
|
- expect(Navigation.commands.setOptions).toHaveBeenCalledTimes(1);
|
|
38
|
|
- expect(Navigation.commands.setOptions).toHaveBeenCalledWith(theContainerId, params);
|
|
39
|
|
- });
|
|
40
|
|
-
|
|
41
|
|
- it('showModal delegates to Commands', async () => {
|
|
42
|
|
- Navigation.commands.showModal.mockReturnValue(Promise.resolve('result'));
|
|
43
|
|
- const params = {};
|
|
44
|
|
- const result = await Navigation.showModal(params);
|
|
45
|
|
- expect(result).toEqual('result');
|
|
46
|
|
- expect(Navigation.commands.showModal).toHaveBeenCalledWith(params);
|
|
47
|
|
- expect(Navigation.commands.showModal).toHaveBeenCalledTimes(1);
|
|
48
|
|
- });
|
|
49
|
|
-
|
|
50
|
|
- it('dismissModal delegates to Commands', async () => {
|
|
51
|
|
- Navigation.commands.dismissModal.mockReturnValue(Promise.resolve('result'));
|
|
52
|
|
- const params = {};
|
|
53
|
|
- const result = await Navigation.dismissModal(params);
|
|
54
|
|
- expect(result).toEqual('result');
|
|
55
|
|
- expect(Navigation.commands.dismissModal).toHaveBeenCalledTimes(1);
|
|
56
|
|
- expect(Navigation.commands.dismissModal).toHaveBeenCalledWith(params);
|
|
57
|
|
- });
|
|
58
|
|
-
|
|
59
|
|
- it('dismissAllModals', async () => {
|
|
60
|
|
- Navigation.commands.dismissAllModals.mockReturnValue(Promise.resolve('result'));
|
|
61
|
|
- const result = await Navigation.dismissAllModals();
|
|
62
|
|
- expect(Navigation.commands.dismissAllModals).toHaveBeenCalledTimes(1);
|
|
63
|
|
- expect(result).toEqual('result');
|
|
64
|
|
- });
|
|
65
|
|
-
|
|
66
|
|
- it('events return public events', () => {
|
|
67
|
|
- const cb = jest.fn();
|
|
68
|
|
- Navigation.events().onAppLaunched(cb);
|
|
69
|
|
- expect(Navigation.nativeEventsReceiver.appLaunched).toHaveBeenCalledTimes(1);
|
|
70
|
|
- expect(Navigation.nativeEventsReceiver.appLaunched).toHaveBeenCalledWith(cb);
|
|
71
|
|
- });
|
|
72
|
|
-
|
|
73
|
|
- it('starts listening and handles internal events', () => {
|
|
74
|
|
- expect(Navigation.nativeEventsReceiver.containerStart).toHaveBeenCalledTimes(1);
|
|
75
|
|
- });
|
|
76
|
|
-
|
|
77
|
|
- it('push delegates to commands', async () => {
|
|
78
|
|
- Navigation.commands.push.mockReturnValue(Promise.resolve('result'));
|
|
79
|
|
- const params = {};
|
|
80
|
|
- const result = await Navigation.push('theContainerId', params);
|
|
81
|
|
- expect(result).toEqual('result');
|
|
82
|
|
- expect(Navigation.commands.push).toHaveBeenCalledWith('theContainerId', params);
|
|
83
|
|
- expect(Navigation.commands.push).toHaveBeenCalledTimes(1);
|
|
84
|
|
- });
|
|
85
|
|
-
|
|
86
|
|
- it('pop delegates to commands', async () => {
|
|
87
|
|
- Navigation.commands.pop.mockReturnValue(Promise.resolve('result'));
|
|
88
|
|
- const result = await Navigation.pop('theContainerId');
|
|
89
|
|
- expect(result).toEqual('result');
|
|
90
|
|
- expect(Navigation.commands.pop).toHaveBeenCalledWith('theContainerId');
|
|
91
|
|
- expect(Navigation.commands.pop).toHaveBeenCalledTimes(1);
|
|
92
|
|
- });
|
|
93
|
|
-
|
|
94
|
|
- it('popTo delegates to commands', async () => {
|
|
95
|
|
- Navigation.commands.popTo.mockReturnValue(Promise.resolve('result'));
|
|
96
|
|
- const params = {};
|
|
97
|
|
- const result = await Navigation.popTo('theContainerId');
|
|
98
|
|
- expect(result).toEqual('result');
|
|
99
|
|
- expect(Navigation.commands.popTo).toHaveBeenCalledWith('theContainerId');
|
|
100
|
|
- expect(Navigation.commands.popTo).toHaveBeenCalledTimes(1);
|
|
101
|
|
- });
|
|
102
|
|
-
|
|
103
|
|
- it('popToRoot delegates to commands', async () => {
|
|
104
|
|
- Navigation.commands.popToRoot.mockReturnValue(Promise.resolve('result'));
|
|
105
|
|
- const params = {};
|
|
106
|
|
- const result = await Navigation.popToRoot('theContainerId');
|
|
107
|
|
- expect(result).toEqual('result');
|
|
108
|
|
- expect(Navigation.commands.popToRoot).toHaveBeenCalledWith('theContainerId');
|
|
109
|
|
- expect(Navigation.commands.popToRoot).toHaveBeenCalledTimes(1);
|
|
110
|
|
- });
|
|
111
|
|
-});
|