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