|
@@ -20,44 +20,41 @@ describe('Commands', () => {
|
20
|
20
|
describe('setRoot', () => {
|
21
|
21
|
it('sends setRoot to native after parsing into a correct layout tree', () => {
|
22
|
22
|
uut.setRoot({
|
23
|
|
- container: {
|
|
23
|
+ component: {
|
24
|
24
|
name: 'com.example.MyScreen'
|
25
|
25
|
}
|
26
|
26
|
});
|
27
|
27
|
expect(mockCommandsSender.setRoot).toHaveBeenCalledTimes(1);
|
28
|
28
|
expect(mockCommandsSender.setRoot).toHaveBeenCalledWith({
|
29
|
|
- type: 'ContainerStack',
|
30
|
|
- id: 'ContainerStack+UNIQUE_ID',
|
31
|
|
- data: {},
|
32
|
|
- children: [
|
33
|
|
- {
|
34
|
|
- type: 'Container',
|
35
|
|
- id: 'Container+UNIQUE_ID',
|
36
|
|
- children: [],
|
37
|
|
- data: {
|
38
|
|
- name: 'com.example.MyScreen',
|
39
|
|
- navigationOptions: {}
|
40
|
|
- }
|
41
|
|
- }
|
42
|
|
- ]
|
|
29
|
+ type: 'Component',
|
|
30
|
+ id: 'Component+UNIQUE_ID',
|
|
31
|
+ children: [],
|
|
32
|
+ data: {
|
|
33
|
+ name: 'com.example.MyScreen',
|
|
34
|
+ navigationOptions: {}
|
|
35
|
+ }
|
43
|
36
|
});
|
44
|
37
|
});
|
45
|
38
|
|
46
|
39
|
it('deep clones input to avoid mutation errors', () => {
|
47
|
40
|
const obj = {};
|
48
|
|
- uut.setRoot({ container: { name: 'bla', inner: obj } });
|
49
|
|
- expect(mockCommandsSender.setRoot.mock.calls[0][0].children[0].data.inner).not.toBe(obj);
|
|
41
|
+ uut.setRoot({ component: { name: 'bla', inner: obj } });
|
|
42
|
+ expect(mockCommandsSender.setRoot.mock.calls[0][0].data.inner).not.toBe(obj);
|
50
|
43
|
});
|
51
|
44
|
|
52
|
45
|
it('passProps into containers', () => {
|
53
|
|
- expect(store.getPropsForContainerId('Container+UNIQUE_ID')).toEqual({});
|
54
|
|
- uut.setRoot(SimpleLayouts.singleScreenWithAditionalParams);
|
55
|
|
- expect(store.getPropsForContainerId('Container+UNIQUE_ID')).toEqual(SimpleLayouts.passProps);
|
|
46
|
+ const passProps = {
|
|
47
|
+ fn: () => 'Hello'
|
|
48
|
+ };
|
|
49
|
+ expect(store.getPropsForContainerId('Component+UNIQUE_ID')).toEqual({});
|
|
50
|
+ uut.setRoot({ component: { name: 'asd', passProps } });
|
|
51
|
+ expect(store.getPropsForContainerId('Component+UNIQUE_ID')).toEqual(passProps);
|
|
52
|
+ expect(store.getPropsForContainerId('Component+UNIQUE_ID').fn()).toEqual('Hello');
|
56
|
53
|
});
|
57
|
54
|
|
58
|
55
|
it('returns a promise with the resolved layout', async () => {
|
59
|
56
|
mockCommandsSender.setRoot.mockReturnValue(Promise.resolve('the resolved layout'));
|
60
|
|
- const result = await uut.setRoot({ container: { name: 'com.example.MyScreen' } });
|
|
57
|
+ const result = await uut.setRoot({ component: { name: 'com.example.MyScreen' } });
|
61
|
58
|
expect(result).toEqual('the resolved layout');
|
62
|
59
|
});
|
63
|
60
|
});
|
|
@@ -87,47 +84,45 @@ describe('Commands', () => {
|
87
|
84
|
describe('showModal', () => {
|
88
|
85
|
it('sends command to native after parsing into a correct layout tree', () => {
|
89
|
86
|
uut.showModal({
|
90
|
|
- container: {
|
|
87
|
+ component: {
|
91
|
88
|
name: 'com.example.MyScreen'
|
92
|
89
|
}
|
93
|
90
|
});
|
94
|
91
|
expect(mockCommandsSender.showModal).toHaveBeenCalledTimes(1);
|
95
|
92
|
expect(mockCommandsSender.showModal).toHaveBeenCalledWith({
|
96
|
|
- type: 'ContainerStack',
|
97
|
|
- id: 'ContainerStack+UNIQUE_ID',
|
98
|
|
- data: {},
|
99
|
|
- children: [{
|
100
|
|
- type: 'Container',
|
101
|
|
- id: 'Container+UNIQUE_ID',
|
102
|
|
- data: {
|
103
|
|
- name: 'com.example.MyScreen',
|
104
|
|
- navigationOptions: {}
|
105
|
|
- },
|
106
|
|
- children: []
|
107
|
|
- }]
|
|
93
|
+ type: 'Component',
|
|
94
|
+ id: 'Component+UNIQUE_ID',
|
|
95
|
+ data: {
|
|
96
|
+ name: 'com.example.MyScreen',
|
|
97
|
+ navigationOptions: {}
|
|
98
|
+ },
|
|
99
|
+ children: []
|
108
|
100
|
});
|
109
|
101
|
});
|
110
|
102
|
|
111
|
103
|
it('deep clones input to avoid mutation errors', () => {
|
112
|
104
|
const obj = {};
|
113
|
|
- uut.showModal({ container: { name: 'name', inner: obj } });
|
|
105
|
+ uut.showModal({ component: { name: 'name', inner: obj } });
|
114
|
106
|
expect(mockCommandsSender.showModal.mock.calls[0][0].data.inner).not.toBe(obj);
|
115
|
107
|
});
|
116
|
108
|
|
117
|
109
|
it('passProps into containers', () => {
|
118
|
|
- expect(store.getPropsForContainerId('Container+UNIQUE_ID')).toEqual({});
|
|
110
|
+ const passProps = {
|
|
111
|
+ fn: () => 'hello'
|
|
112
|
+ };
|
|
113
|
+ expect(store.getPropsForContainerId('Component+UNIQUE_ID')).toEqual({});
|
119
|
114
|
uut.showModal({
|
120
|
|
- container: {
|
|
115
|
+ component: {
|
121
|
116
|
name: 'com.example.MyScreen',
|
122
|
|
- passProps: SimpleLayouts.passProps
|
|
117
|
+ passProps
|
123
|
118
|
}
|
124
|
119
|
});
|
125
|
|
- expect(store.getPropsForContainerId('Container+UNIQUE_ID')).toEqual(SimpleLayouts.passProps);
|
|
120
|
+ expect(store.getPropsForContainerId('Component+UNIQUE_ID')).toEqual(passProps);
|
126
|
121
|
});
|
127
|
122
|
|
128
|
123
|
it('returns a promise with the resolved layout', async () => {
|
129
|
124
|
mockCommandsSender.showModal.mockReturnValue(Promise.resolve('the resolved layout'));
|
130
|
|
- const result = await uut.showModal({ container: { name: 'com.example.MyScreen' } });
|
|
125
|
+ const result = await uut.showModal({ component: { name: 'com.example.MyScreen' } });
|
131
|
126
|
expect(result).toEqual('the resolved layout');
|
132
|
127
|
});
|
133
|
128
|
});
|
|
@@ -163,22 +158,22 @@ describe('Commands', () => {
|
163
|
158
|
describe('push', () => {
|
164
|
159
|
it('deep clones input to avoid mutation errors', () => {
|
165
|
160
|
const obj = {};
|
166
|
|
- uut.push('theContainerId', { name: 'name', inner: { foo: obj } });
|
167
|
|
- expect(mockCommandsSender.push.mock.calls[0][1].data.inner.foo).not.toBe(obj);
|
|
161
|
+ uut.push('theContainerId', { component: { name: 'name', passProps: { foo: obj } } });
|
|
162
|
+ expect(mockCommandsSender.push.mock.calls[0][1].data.passProps.foo).not.toBe(obj);
|
168
|
163
|
});
|
169
|
164
|
|
170
|
165
|
it('resolves with the parsed layout', async () => {
|
171
|
166
|
mockCommandsSender.push.mockReturnValue(Promise.resolve('the resolved layout'));
|
172
|
|
- const result = await uut.push('theContainerId', { name: 'com.example.MyScreen' });
|
|
167
|
+ const result = await uut.push('theContainerId', { component: { name: 'com.example.MyScreen' } });
|
173
|
168
|
expect(result).toEqual('the resolved layout');
|
174
|
169
|
});
|
175
|
170
|
|
176
|
171
|
it('parses into correct layout node and sends to native', () => {
|
177
|
|
- uut.push('theContainerId', { name: 'com.example.MyScreen' });
|
|
172
|
+ uut.push('theContainerId', { component: { name: 'com.example.MyScreen' } });
|
178
|
173
|
expect(mockCommandsSender.push).toHaveBeenCalledTimes(1);
|
179
|
174
|
expect(mockCommandsSender.push).toHaveBeenCalledWith('theContainerId', {
|
180
|
|
- type: 'Container',
|
181
|
|
- id: 'Container+UNIQUE_ID',
|
|
175
|
+ type: 'Component',
|
|
176
|
+ id: 'Component+UNIQUE_ID',
|
182
|
177
|
data: {
|
183
|
178
|
name: 'com.example.MyScreen',
|
184
|
179
|
navigationOptions: {}
|
|
@@ -201,7 +196,8 @@ describe('Commands', () => {
|
201
|
196
|
{ type: 'sharedElement', fromId: 'title2', toId: 'title1', startDelay: 0, springVelocity: 0.2, duration: 0.5 }
|
202
|
197
|
],
|
203
|
198
|
duration: 0.8
|
204
|
|
- } };
|
|
199
|
+ }
|
|
200
|
+ };
|
205
|
201
|
uut.pop('theContainerId', options);
|
206
|
202
|
expect(mockCommandsSender.pop).toHaveBeenCalledTimes(1);
|
207
|
203
|
expect(mockCommandsSender.pop).toHaveBeenCalledWith('theContainerId', options);
|
|
@@ -242,7 +238,7 @@ describe('Commands', () => {
|
242
|
238
|
});
|
243
|
239
|
});
|
244
|
240
|
|
245
|
|
- describe('showOverlay', () => {
|
|
241
|
+ xdescribe('showOverlay', () => {
|
246
|
242
|
it('deep clones input to avoid mutation errors', () => {
|
247
|
243
|
const obj = { title: 'test' };
|
248
|
244
|
uut.showOverlay('alert', obj);
|