|
@@ -4,25 +4,116 @@ describe('LayoutTreeParser', () => {
|
4
|
4
|
let uut;
|
5
|
5
|
|
6
|
6
|
beforeEach(() => {
|
7
|
|
- const uniqueIdProvider = {generate: (p) => `${p}UNIQUE_ID`};
|
|
7
|
+ const uniqueIdProvider = {generate: (prefix) => `${prefix}+UNIQUE_ID`};
|
8
|
8
|
const LayoutTreeParser = require('./LayoutTreeParser').default;
|
9
|
9
|
uut = new LayoutTreeParser(uniqueIdProvider);
|
10
|
10
|
});
|
11
|
11
|
|
12
|
|
- it('returns a deep clone', () => {
|
13
|
|
- const input = {inner: {foo: {bar: 1}}};
|
14
|
|
- expect(uut.parse(input)).not.toBe(input);
|
15
|
|
- expect(uut.parse(input).inner).not.toBe(input.inner);
|
16
|
|
- expect(uut.parse(input).inner.foo).not.toBe(input.inner.foo);
|
|
12
|
+ it('parses single screen', () => {
|
|
13
|
+ expect(uut.parseSimpleApi(SimpleLayouts.singleScreenApp))
|
|
14
|
+ .toEqual({
|
|
15
|
+ type: 'ContainerStack',
|
|
16
|
+ id: 'ContainerStack+UNIQUE_ID',
|
|
17
|
+ children: [
|
|
18
|
+ {
|
|
19
|
+ type: 'Container',
|
|
20
|
+ id: 'Container+UNIQUE_ID',
|
|
21
|
+ data: {
|
|
22
|
+ name: 'com.example.MyScreen'
|
|
23
|
+ },
|
|
24
|
+ children: []
|
|
25
|
+ }
|
|
26
|
+ ]
|
|
27
|
+ });
|
17
|
28
|
});
|
18
|
29
|
|
19
|
|
- it('adds uniqueId to containers', () => {
|
|
30
|
+ it('parses single screen with props', () => {
|
|
31
|
+ expect(uut.parseSimpleApi(SimpleLayouts.singleScreenWithAditionalParams))
|
|
32
|
+ .toEqual({
|
|
33
|
+ type: 'ContainerStack',
|
|
34
|
+ id: 'ContainerStack+UNIQUE_ID',
|
|
35
|
+ children: [
|
|
36
|
+ {
|
|
37
|
+ type: 'Container',
|
|
38
|
+ id: 'Container+UNIQUE_ID',
|
|
39
|
+ children: [],
|
|
40
|
+ data: {
|
|
41
|
+ name: 'com.example.MyScreen',
|
|
42
|
+ passProps: {
|
|
43
|
+ foo: {
|
|
44
|
+ number: 1,
|
|
45
|
+ string: 'Hello!'
|
|
46
|
+ },
|
|
47
|
+ bar: SimpleLayouts.passedFunction
|
|
48
|
+ },
|
|
49
|
+ style: {},
|
|
50
|
+ buttons: {}
|
|
51
|
+ }
|
|
52
|
+ }
|
|
53
|
+ ]
|
|
54
|
+ });
|
|
55
|
+ });
|
|
56
|
+
|
|
57
|
+ xit('parses tab based', () => {
|
|
58
|
+ expect(uut.parseSimpleApi(SimpleLayouts.tabBasedApp))
|
|
59
|
+ .toEqual({
|
|
60
|
+ type: 'Tabs',
|
|
61
|
+ id: 'Tabs+UNIQUE_ID',
|
|
62
|
+ children: [
|
|
63
|
+ {
|
|
64
|
+ container: {
|
|
65
|
+ name: 'com.example.FirstTab'
|
|
66
|
+ }
|
|
67
|
+ },
|
|
68
|
+ {
|
|
69
|
+ container: {
|
|
70
|
+ name: 'com.example.SecondTab'
|
|
71
|
+ }
|
|
72
|
+ },
|
|
73
|
+ {
|
|
74
|
+ container: {
|
|
75
|
+ name: 'com.example.FirstTab'
|
|
76
|
+ }
|
|
77
|
+ }
|
|
78
|
+ ]
|
|
79
|
+ });
|
|
80
|
+ });
|
|
81
|
+
|
|
82
|
+ xit('adds uniqueId to containers', () => {
|
20
|
83
|
const input = {container: {}};
|
21
|
|
- expect(uut.parse(input)).toEqual({container: {id: 'containerUNIQUE_ID'}});
|
|
84
|
+ expect(uut.parse(input)).toEqual({container: {id: 'Container+UNIQUE_ID'}});
|
22
|
85
|
});
|
23
|
86
|
|
24
|
|
- it('parses simple structures', () => {
|
25
|
|
- uut.parse(SimpleLayouts.singleScreenApp);
|
26
|
|
- //TODO
|
|
87
|
+ xit('parses side menus', () => {
|
|
88
|
+ //const result2 = {
|
|
89
|
+ // type: 'Menus',
|
|
90
|
+ // id: 'MenusUNIQUE_ID',
|
|
91
|
+ // children: [
|
|
92
|
+ // {
|
|
93
|
+ // type: 'Container',
|
|
94
|
+ // id: 'ContainerUNIQUE_ID',
|
|
95
|
+ // name: 'com.example.LeftSideMenu',
|
|
96
|
+ // children: []
|
|
97
|
+ // },
|
|
98
|
+ // {
|
|
99
|
+ // type: 'ContainerStack',
|
|
100
|
+ // id: 'ContainerStackUNIQUE_ID',
|
|
101
|
+ // children: [
|
|
102
|
+ // {
|
|
103
|
+ // type: 'Container',
|
|
104
|
+ // id: 'ContainerUNIQUE_ID',
|
|
105
|
+ // name: 'com.example.WelcomeScreen',
|
|
106
|
+ // children: []
|
|
107
|
+ // }
|
|
108
|
+ // ]
|
|
109
|
+ // },
|
|
110
|
+ // {
|
|
111
|
+ // type: 'Container',
|
|
112
|
+ // id: 'ContainerUNIQUE_ID',
|
|
113
|
+ // name: 'com.example.RightSideMenu',
|
|
114
|
+ // children: []
|
|
115
|
+ // }
|
|
116
|
+ // ]
|
|
117
|
+ //};
|
27
|
118
|
});
|
28
|
119
|
});
|