|
@@ -1,19 +1,33 @@
|
1
|
1
|
describe('LayoutBuilder', () => {
|
2
|
|
- let uut;
|
|
2
|
+ let LayoutBuilder;
|
3
|
3
|
|
4
|
4
|
beforeEach(() => {
|
5
|
5
|
jest.mock('../providers/UniqueIdProvider');
|
6
|
|
- uut = require('./LayoutBuilder');
|
|
6
|
+ LayoutBuilder = require('./LayoutBuilder');
|
7
|
7
|
});
|
8
|
8
|
|
9
|
9
|
describe('parse', () => {
|
10
|
|
- it('returns a new object', () => {
|
11
|
|
- const input = {};
|
12
|
|
- expect(uut.parse(input)).not.toBe(input);
|
|
10
|
+ it('deeply clones input params', () => {
|
|
11
|
+ const input = {inner: {value: 1}};
|
|
12
|
+ expect(LayoutBuilder.parse(input)).not.toBe(input);
|
|
13
|
+ expect(LayoutBuilder.parse(input).inner).not.toBe(input.inner);
|
|
14
|
+ });
|
|
15
|
+
|
|
16
|
+ it('adds uniqueId to passed container', () => {
|
|
17
|
+ expect(LayoutBuilder.parse({
|
|
18
|
+ container: {
|
|
19
|
+ key: 'com.example.MyScreen'
|
|
20
|
+ }
|
|
21
|
+ })).toEqual({
|
|
22
|
+ container: {
|
|
23
|
+ key: 'com.example.MyScreen',
|
|
24
|
+ id: 'containerUNIQUE'
|
|
25
|
+ }
|
|
26
|
+ });
|
13
|
27
|
});
|
14
|
28
|
|
15
|
29
|
it('adds uniqueId to passed sideMenu', () => {
|
16
|
|
- expect(uut.parse({
|
|
30
|
+ expect(LayoutBuilder.parse({
|
17
|
31
|
container: {
|
18
|
32
|
key: 'com.example.MyScreen'
|
19
|
33
|
},
|
|
@@ -28,30 +42,78 @@ describe('LayoutBuilder', () => {
|
28
|
42
|
})).toEqual({
|
29
|
43
|
container: {
|
30
|
44
|
key: 'com.example.MyScreen',
|
31
|
|
- id: 'container123'
|
|
45
|
+ id: 'containerUNIQUE'
|
32
|
46
|
},
|
33
|
47
|
sideMenu: {
|
34
|
48
|
left: {
|
35
|
49
|
key: 'com.example.SideMenu1',
|
36
|
|
- id: 'container123'
|
|
50
|
+ id: 'containerUNIQUE'
|
37
|
51
|
},
|
38
|
52
|
right: {
|
39
|
53
|
key: 'com.example.SideMenu2',
|
40
|
|
- id: 'container123'
|
|
54
|
+ id: 'containerUNIQUE'
|
41
|
55
|
}
|
42
|
56
|
}
|
43
|
57
|
});
|
44
|
58
|
});
|
45
|
59
|
|
46
|
|
- it('adds uniqueId to passed container', () => {
|
47
|
|
- expect(uut.parse({
|
48
|
|
- container: {
|
49
|
|
- key: 'com.example.MyScreen'
|
|
60
|
+ it('adds uniqueId to passed tabs', () => {
|
|
61
|
+ expect(LayoutBuilder.parse({
|
|
62
|
+ tabs: [
|
|
63
|
+ {
|
|
64
|
+ container: {
|
|
65
|
+ key: 'com.example.FirstTab'
|
|
66
|
+ }
|
|
67
|
+ },
|
|
68
|
+ {
|
|
69
|
+ container: {
|
|
70
|
+ key: 'com.example.SecondTab'
|
|
71
|
+ }
|
|
72
|
+ },
|
|
73
|
+ {
|
|
74
|
+ container: {
|
|
75
|
+ key: 'com.example.FirstTab'
|
|
76
|
+ }
|
|
77
|
+ }
|
|
78
|
+ ],
|
|
79
|
+ sideMenu: {
|
|
80
|
+ left: {
|
|
81
|
+ key: 'com.example.Menu1'
|
|
82
|
+ },
|
|
83
|
+ right: {
|
|
84
|
+ key: 'com.example.Menu2'
|
|
85
|
+ }
|
50
|
86
|
}
|
51
|
87
|
})).toEqual({
|
52
|
|
- container: {
|
53
|
|
- key: 'com.example.MyScreen',
|
54
|
|
- id: 'container123'
|
|
88
|
+ tabs: [
|
|
89
|
+ {
|
|
90
|
+ container: {
|
|
91
|
+ key: 'com.example.FirstTab',
|
|
92
|
+ id: 'containerUNIQUE'
|
|
93
|
+ }
|
|
94
|
+ },
|
|
95
|
+ {
|
|
96
|
+ container: {
|
|
97
|
+ key: 'com.example.SecondTab',
|
|
98
|
+ id: 'containerUNIQUE'
|
|
99
|
+ }
|
|
100
|
+ },
|
|
101
|
+ {
|
|
102
|
+ container: {
|
|
103
|
+ key: 'com.example.FirstTab',
|
|
104
|
+ id: 'containerUNIQUE'
|
|
105
|
+ }
|
|
106
|
+ }
|
|
107
|
+ ],
|
|
108
|
+ sideMenu: {
|
|
109
|
+ left: {
|
|
110
|
+ key: 'com.example.Menu1',
|
|
111
|
+ id: 'containerUNIQUE'
|
|
112
|
+ },
|
|
113
|
+ right: {
|
|
114
|
+ key: 'com.example.Menu2',
|
|
115
|
+ id: 'containerUNIQUE'
|
|
116
|
+ }
|
55
|
117
|
}
|
56
|
118
|
});
|
57
|
119
|
});
|