|
@@ -13,34 +13,75 @@ describe('LayoutTreeCrawler', () => {
|
13
|
13
|
});
|
14
|
14
|
|
15
|
15
|
it('crawls a layout tree and adds unique id to each node', () => {
|
16
|
|
- const node = { type: LayoutTypes.Container, children: [{ type: LayoutTypes.BottomTabs }] };
|
|
16
|
+ const node = { type: LayoutTypes.ContainerStack, children: [{ type: LayoutTypes.BottomTabs }] };
|
17
|
17
|
uut.crawl(node);
|
18
|
|
- expect(node.id).toEqual('Container+UNIQUE_ID');
|
|
18
|
+ expect(node.id).toEqual('ContainerStack+UNIQUE_ID');
|
19
|
19
|
expect(node.children[0].id).toEqual('BottomTabs+UNIQUE_ID');
|
20
|
20
|
});
|
21
|
21
|
|
22
|
22
|
it('crawls a layout tree and ensures data exists', () => {
|
23
|
|
- const node = { type: LayoutTypes.Container, children: [{ type: LayoutTypes.BottomTabs }] };
|
|
23
|
+ const node = { type: LayoutTypes.ContainerStack, children: [{ type: LayoutTypes.BottomTabs }] };
|
24
|
24
|
uut.crawl(node);
|
25
|
25
|
expect(node.data).toEqual({});
|
26
|
26
|
expect(node.children[0].data).toEqual({});
|
27
|
27
|
});
|
28
|
28
|
|
29
|
29
|
it('crawls a layout tree and ensures children exists', () => {
|
30
|
|
- const node = { type: LayoutTypes.Container, children: [{ type: LayoutTypes.BottomTabs }] };
|
|
30
|
+ const node = { type: LayoutTypes.ContainerStack, children: [{ type: LayoutTypes.BottomTabs }] };
|
31
|
31
|
uut.crawl(node);
|
32
|
32
|
expect(node.children[0].children).toEqual([]);
|
33
|
33
|
});
|
34
|
34
|
|
35
|
35
|
it('crawls a layout tree and asserts known layout type', () => {
|
36
|
|
- const node = { type: LayoutTypes.Container, children: [{ type: 'Bob' }] };
|
|
36
|
+ const node = { type: LayoutTypes.ContainerStack, children: [{ type: 'Bob' }] };
|
37
|
37
|
expect(() => uut.crawl(node)).toThrow(new Error('Unknown layout type Bob'));
|
38
|
38
|
});
|
39
|
39
|
|
40
|
40
|
it('saves passProps into store for Container nodes', () => {
|
41
|
|
- const node = { type: LayoutTypes.BottomTabs, children: [{ type: LayoutTypes.Container, data: { passProps: { myProp: 123 } } }] };
|
|
41
|
+ const node = {
|
|
42
|
+ type: LayoutTypes.BottomTabs, children: [
|
|
43
|
+ { type: LayoutTypes.Container, data: { name: 'the name', passProps: { myProp: 123 } } }]
|
|
44
|
+ };
|
42
|
45
|
expect(store.getPropsForContainerId('Container+UNIQUE_ID')).toEqual({});
|
43
|
46
|
uut.crawl(node);
|
44
|
47
|
expect(store.getPropsForContainerId('Container+UNIQUE_ID')).toEqual({ myProp: 123 });
|
45
|
48
|
});
|
|
49
|
+
|
|
50
|
+ it('Containers: injects navigationStyle from original container class static property', () => {
|
|
51
|
+ const theStyle = {};
|
|
52
|
+ const MyContainer = class {
|
|
53
|
+ static navigationStyle = theStyle;
|
|
54
|
+ };
|
|
55
|
+
|
|
56
|
+ const node = { type: LayoutTypes.Container, data: { name: 'theContainerName' } };
|
|
57
|
+ store.setOriginalContainerClassForName('theContainerName', MyContainer);
|
|
58
|
+ uut.crawl(node);
|
|
59
|
+ expect(node.data.navigationStyle).toEqual(theStyle);
|
|
60
|
+ });
|
|
61
|
+
|
|
62
|
+ it('Containers: deepClones navigationStyle', () => {
|
|
63
|
+ const theStyle = {};
|
|
64
|
+ const MyContainer = class {
|
|
65
|
+ static navigationStyle = theStyle;
|
|
66
|
+ };
|
|
67
|
+
|
|
68
|
+ const node = { type: LayoutTypes.Container, data: { name: 'theContainerName' } };
|
|
69
|
+ store.setOriginalContainerClassForName('theContainerName', MyContainer);
|
|
70
|
+ uut.crawl(node);
|
|
71
|
+ expect(node.data.navigationStyle).not.toBe(theStyle);
|
|
72
|
+ });
|
|
73
|
+
|
|
74
|
+ it('Containers: must contain data name', () => {
|
|
75
|
+ const node = { type: LayoutTypes.Container, data: {} };
|
|
76
|
+ expect(() => uut.crawl(node)).toThrow(new Error('Missing container data.name'));
|
|
77
|
+ });
|
|
78
|
+
|
|
79
|
+ it('Containers: navigationStyle default obj', () => {
|
|
80
|
+ const MyContainer = class { };
|
|
81
|
+
|
|
82
|
+ const node = { type: LayoutTypes.Container, data: { name: 'theContainerName' } };
|
|
83
|
+ store.setOriginalContainerClassForName('theContainerName', MyContainer);
|
|
84
|
+ uut.crawl(node);
|
|
85
|
+ expect(node.data.navigationStyle).toEqual({});
|
|
86
|
+ });
|
46
|
87
|
});
|