react-native-navigation的迁移库

LayoutTreeParser.test.js 2.9KB

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