|
|
@@ -62,4 +62,43 @@ describe('AppCommands', () => {
|
|
62
|
62
|
expect(result).toEqual('the resolved layout');
|
|
63
|
63
|
});
|
|
64
|
64
|
});
|
|
|
65
|
+
|
|
|
66
|
+
|
|
|
67
|
+ describe('showModal', () => {
|
|
|
68
|
+ it('sends command to native after parsing into a correct layout tree', () => {
|
|
|
69
|
+ uut.showModal({
|
|
|
70
|
+ name: 'com.example.MyScreen'
|
|
|
71
|
+ });
|
|
|
72
|
+ expect(mockCommandsSender.showModal).toHaveBeenCalledTimes(1);
|
|
|
73
|
+ expect(mockCommandsSender.showModal).toHaveBeenCalledWith({
|
|
|
74
|
+ type: 'Container',
|
|
|
75
|
+ id: 'Container+UNIQUE_ID',
|
|
|
76
|
+ children: [],
|
|
|
77
|
+ data: {
|
|
|
78
|
+ name: 'com.example.MyScreen'
|
|
|
79
|
+ }
|
|
|
80
|
+ });
|
|
|
81
|
+ });
|
|
|
82
|
+
|
|
|
83
|
+ it('deep clones input to avoid mutation errors', () => {
|
|
|
84
|
+ const obj = {};
|
|
|
85
|
+ uut.showModal({ inner: obj });
|
|
|
86
|
+ expect(mockCommandsSender.showModal.mock.calls[0][0].data.inner).not.toBe(obj);
|
|
|
87
|
+ });
|
|
|
88
|
+
|
|
|
89
|
+ it('passProps into containers', () => {
|
|
|
90
|
+ expect(store.getPropsForContainerId('Container+UNIQUE_ID')).toEqual({});
|
|
|
91
|
+ uut.showModal({
|
|
|
92
|
+ name: 'com.example.MyScreen',
|
|
|
93
|
+ passProps: SimpleLayouts.passProps
|
|
|
94
|
+ });
|
|
|
95
|
+ expect(store.getPropsForContainerId('Container+UNIQUE_ID')).toEqual(SimpleLayouts.passProps);
|
|
|
96
|
+ });
|
|
|
97
|
+
|
|
|
98
|
+ it('returns a promise with the resolved layout', async () => {
|
|
|
99
|
+ mockCommandsSender.showModal.mockReturnValue(Promise.resolve('the resolved layout'));
|
|
|
100
|
+ const result = await uut.showModal({ container: { name: 'com.example.MyScreen' } });
|
|
|
101
|
+ expect(result).toEqual('the resolved layout');
|
|
|
102
|
+ });
|
|
|
103
|
+ });
|
|
65
|
104
|
});
|