|
@@ -8,53 +8,53 @@ describe('navigation options', () => {
|
8
|
8
|
beforeEach(() => {
|
9
|
9
|
options = {};
|
10
|
10
|
store = new Store();
|
11
|
|
- uut = new OptionsProcessor();
|
|
11
|
+ uut = new OptionsProcessor(store);
|
12
|
12
|
});
|
13
|
13
|
|
14
|
14
|
it('processes colors into numeric AARRGGBB', () => {
|
15
|
15
|
options.someKeyColor = 'red';
|
16
|
16
|
options.color = 'blue';
|
17
|
|
- uut.processOptions(options, store);
|
|
17
|
+ uut.processOptions(options);
|
18
|
18
|
expect(options.someKeyColor).toEqual(0xffff0000);
|
19
|
19
|
expect(options.color).toEqual(0xff0000ff);
|
20
|
20
|
|
21
|
21
|
options.someKeyColor = 'yellow';
|
22
|
|
- uut.processOptions(options, store);
|
|
22
|
+ uut.processOptions(options);
|
23
|
23
|
expect(options.someKeyColor).toEqual(0xffffff00);
|
24
|
24
|
});
|
25
|
25
|
|
26
|
26
|
it('processes numeric colors', () => {
|
27
|
27
|
options.someKeyColor = '#123456';
|
28
|
|
- uut.processOptions(options, store);
|
|
28
|
+ uut.processOptions(options);
|
29
|
29
|
expect(options.someKeyColor).toEqual(0xff123456);
|
30
|
30
|
|
31
|
31
|
options.someKeyColor = 0x123456ff; // wut
|
32
|
|
- uut.processOptions(options, store);
|
|
32
|
+ uut.processOptions(options);
|
33
|
33
|
expect(options.someKeyColor).toEqual(0xff123456);
|
34
|
34
|
});
|
35
|
35
|
|
36
|
36
|
it('process colors with rgb functions', () => {
|
37
|
37
|
options.someKeyColor = 'rgb(255, 0, 255)';
|
38
|
|
- uut.processOptions(options, store);
|
|
38
|
+ uut.processOptions(options);
|
39
|
39
|
expect(options.someKeyColor).toEqual(0xffff00ff);
|
40
|
40
|
});
|
41
|
41
|
|
42
|
42
|
it('process colors with special words', () => {
|
43
|
43
|
options.someKeyColor = 'fuchsia';
|
44
|
|
- uut.processOptions(options, store);
|
|
44
|
+ uut.processOptions(options);
|
45
|
45
|
expect(options.someKeyColor).toEqual(0xffff00ff);
|
46
|
46
|
});
|
47
|
47
|
|
48
|
48
|
it('process colors with hsla functions', () => {
|
49
|
49
|
options.someKeyColor = 'hsla(360, 100%, 100%, 1.0)';
|
50
|
|
- uut.processOptions(options, store);
|
|
50
|
+ uut.processOptions(options);
|
51
|
51
|
|
52
|
52
|
expect(options.someKeyColor).toEqual(0xffffffff);
|
53
|
53
|
});
|
54
|
54
|
|
55
|
55
|
it('unknown colors return undefined', () => {
|
56
|
56
|
options.someKeyColor = 'wut';
|
57
|
|
- uut.processOptions(options, store);
|
|
57
|
+ uut.processOptions(options);
|
58
|
58
|
expect(options.someKeyColor).toEqual(undefined);
|
59
|
59
|
});
|
60
|
60
|
|
|
@@ -62,7 +62,7 @@ describe('navigation options', () => {
|
62
|
62
|
options.otherKeyColor = 'red';
|
63
|
63
|
options.yetAnotherColor = 'blue';
|
64
|
64
|
options.andAnotherColor = 'rgb(0, 255, 0)';
|
65
|
|
- uut.processOptions(options, store);
|
|
65
|
+ uut.processOptions(options);
|
66
|
66
|
expect(options.otherKeyColor).toEqual(0xffff0000);
|
67
|
67
|
expect(options.yetAnotherColor).toEqual(0xff0000ff);
|
68
|
68
|
expect(options.andAnotherColor).toEqual(0xff00ff00);
|
|
@@ -70,14 +70,14 @@ describe('navigation options', () => {
|
70
|
70
|
|
71
|
71
|
it('keys ending with Color case sensitive', () => {
|
72
|
72
|
options.otherKey_color = 'red'; // eslint-disable-line camelcase
|
73
|
|
- uut.processOptions(options, store);
|
|
73
|
+ uut.processOptions(options);
|
74
|
74
|
expect(options.otherKey_color).toEqual('red');
|
75
|
75
|
});
|
76
|
76
|
|
77
|
77
|
it('any nested recursive keys ending with Color', () => {
|
78
|
78
|
options.topBar = { textColor: 'red' };
|
79
|
79
|
options.topBar.innerMostObj = { anotherColor: 'yellow' };
|
80
|
|
- uut.processOptions(options, store);
|
|
80
|
+ uut.processOptions(options);
|
81
|
81
|
expect(options.topBar.textColor).toEqual(0xffff0000);
|
82
|
82
|
expect(options.topBar.innerMostObj.anotherColor).toEqual(0xffffff00);
|
83
|
83
|
});
|
|
@@ -90,7 +90,7 @@ describe('navigation options', () => {
|
90
|
90
|
myIcon: 'require("https://wix.github.io/react-native-navigation/_images/logo.png");',
|
91
|
91
|
myOtherValue: 'value'
|
92
|
92
|
};
|
93
|
|
- uut.processOptions(options, store);
|
|
93
|
+ uut.processOptions(options);
|
94
|
94
|
|
95
|
95
|
// As we can't import external images and we don't want to add an image here
|
96
|
96
|
// I assign the icons to strings (what the require would generally look like)
|
|
@@ -106,7 +106,7 @@ describe('navigation options', () => {
|
106
|
106
|
const passProps = { prop: 'prop' };
|
107
|
107
|
options.rightButtons = [{ passProps, id: '1' }];
|
108
|
108
|
|
109
|
|
- uut.processOptions({ o: options }, store);
|
|
109
|
+ uut.processOptions({ o: options });
|
110
|
110
|
|
111
|
111
|
expect(store.getPropsForId('1')).toEqual(passProps);
|
112
|
112
|
});
|
|
@@ -115,7 +115,7 @@ describe('navigation options', () => {
|
115
|
115
|
const passProps = { prop: 'prop' };
|
116
|
116
|
options.rightButtons = [{ passProps }];
|
117
|
117
|
|
118
|
|
- uut.processOptions({ o: options }, store);
|
|
118
|
+ uut.processOptions({ o: options });
|
119
|
119
|
|
120
|
120
|
expect(store.getPropsForId('1')).toEqual({});
|
121
|
121
|
});
|
|
@@ -125,14 +125,14 @@ describe('navigation options', () => {
|
125
|
125
|
options.topBar = { textColor: 'red' };
|
126
|
126
|
options.topBar.innerMostObj = { anotherColor: 'yellow' };
|
127
|
127
|
|
128
|
|
- uut.processOptions({ o: options }, store);
|
|
128
|
+ uut.processOptions({ o: options });
|
129
|
129
|
|
130
|
130
|
expect(options.topBar.textColor).toEqual(0xffff0000);
|
131
|
131
|
});
|
132
|
132
|
|
133
|
133
|
it('undefined value return undefined ', () => {
|
134
|
134
|
options.someImage = undefined;
|
135
|
|
- uut.processOptions(options, store);
|
|
135
|
+ uut.processOptions(options);
|
136
|
136
|
|
137
|
137
|
expect(options.someImage).toEqual(undefined);
|
138
|
138
|
});
|