|
@@ -1,32 +1,71 @@
|
1
|
1
|
describe('Commands', () => {
|
2
|
2
|
let uut;
|
|
3
|
+ let mockNativeNavigation;
|
|
4
|
+ let mockUniqueIdProvider;
|
3
|
5
|
|
4
|
6
|
beforeEach(() => {
|
|
7
|
+ mockNativeNavigation = {
|
|
8
|
+ startApp: jest.fn()
|
|
9
|
+ };
|
|
10
|
+ require('react-native').NativeModules.NativeNavigation = mockNativeNavigation;
|
|
11
|
+ jest.mock('../providers/UniqueIdProvider');
|
|
12
|
+ mockUniqueIdProvider = require('../providers/UniqueIdProvider');
|
5
|
13
|
uut = require('./Commands');
|
6
|
14
|
});
|
7
|
15
|
|
8
|
16
|
describe('startApp', () => {
|
9
|
|
- it('receives params object', () => {
|
|
17
|
+ it('sends startApp to native', () => {
|
10
|
18
|
uut.startApp({
|
11
|
|
- containerKey: {
|
12
|
|
- root: 'example.MyContainer'
|
13
|
|
- },
|
14
|
|
- drawer: {
|
15
|
|
- left: {
|
16
|
|
- root: 'example.SideMenu'
|
17
|
|
- }
|
|
19
|
+ container: {
|
|
20
|
+ key: 'example.MyContainer'
|
18
|
21
|
}
|
19
|
22
|
});
|
|
23
|
+ expect(mockNativeNavigation.startApp).toHaveBeenCalledTimes(1);
|
20
|
24
|
});
|
21
|
25
|
|
22
|
|
- it('expects to get containerKey, or tabs with containerKeys', () => {
|
23
|
|
- expect(() => uut.startApp({containerKey: 'example.MyContainer'})).not.toThrow();
|
24
|
|
- expect(() => uut.startApp({tabs: [{containerKey: 'example.Tab1'}]})).not.toThrow();
|
25
|
|
- expect(() => uut.startApp()).toThrow();
|
26
|
|
- expect(() => uut.startApp({})).toThrow();
|
27
|
|
- expect(() => uut.startApp({tabs: []})).toThrow();
|
28
|
|
- expect(() => uut.startApp({tabs: [{}]})).toThrow();
|
29
|
|
- expect(() => uut.startApp({tabs: [{containerKey: 'example.Tab1'}, {}]})).toThrow();
|
|
26
|
+ it('parses the params and construct single screen hirarchy', () => {
|
|
27
|
+ mockUniqueIdProvider.uniqueId = jest.fn((prefix) => `${prefix}123`);
|
|
28
|
+
|
|
29
|
+ expect(uut.parse(
|
|
30
|
+ {
|
|
31
|
+ container: {
|
|
32
|
+ key: 'com.example.MyScreen'
|
|
33
|
+ }
|
|
34
|
+ })).toEqual(
|
|
35
|
+ {
|
|
36
|
+ containerStack: {
|
|
37
|
+ id: 'containerStack123',
|
|
38
|
+ stack: [
|
|
39
|
+ {
|
|
40
|
+ container: {
|
|
41
|
+ key: 'com.example.MyScreen',
|
|
42
|
+ id: 'container123'
|
|
43
|
+ }
|
|
44
|
+ }
|
|
45
|
+ ]
|
|
46
|
+ }
|
|
47
|
+ });
|
30
|
48
|
});
|
|
49
|
+ //it('receives params object', () => {
|
|
50
|
+ // uut.startApp({
|
|
51
|
+ // container: {
|
|
52
|
+ // key: 'example.MyContainer'
|
|
53
|
+ // },
|
|
54
|
+ // drawer: {
|
|
55
|
+ // left: {
|
|
56
|
+ // key: 'example.SideMenu'
|
|
57
|
+ // }
|
|
58
|
+ // }
|
|
59
|
+ // });
|
|
60
|
+ //});
|
|
61
|
+ //it('expects to get containerKey, or tabs with containerKeys', () => {
|
|
62
|
+ // expect(() => uut.startApp({containerKey: 'example.MyContainer'})).not.toThrow();
|
|
63
|
+ // expect(() => uut.startApp({tabs: [{containerKey: 'example.Tab1'}]})).not.toThrow();
|
|
64
|
+ // expect(() => uut.startApp()).toThrow();
|
|
65
|
+ // expect(() => uut.startApp({})).toThrow();
|
|
66
|
+ // expect(() => uut.startApp({tabs: []})).toThrow();
|
|
67
|
+ // expect(() => uut.startApp({tabs: [{}]})).toThrow();
|
|
68
|
+ // expect(() => uut.startApp({tabs: [{containerKey: 'example.Tab1'}, {}]})).toThrow();
|
|
69
|
+ //});
|
31
|
70
|
});
|
32
|
71
|
});
|