@applicaster/zapp-react-native-ui-components 16.0.0-rc.100 → 16.0.0-rc.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -129,8 +129,7 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
129
129
  * The last scene in the array is removed in the "backTransitionEnd" callback,
130
130
  * only after the animation is complete.
131
131
  */
132
- backTransitionStart() {
133
- const previousRoute = this.props.navigator?.currentRoute;
132
+ backTransitionStart(previousRoute: string) {
134
133
  const currentRoute = this.props.navigator?.currentRoute;
135
134
 
136
135
  const diffLengthRoutes =
@@ -242,7 +241,7 @@ export class TransitionerComponent extends React.PureComponent<Props, State> {
242
241
  break;
243
242
 
244
243
  case NAV_ACTION_BACK: {
245
- this.backTransitionStart();
244
+ this.backTransitionStart(previousRoute);
246
245
  break;
247
246
  }
248
247
 
@@ -1,8 +1,13 @@
1
1
  import React from "react";
2
2
  import { Text, View } from "react-native";
3
3
 
4
- import { TransitionerComponent } from "../Transitioner";
5
- import { render } from "@testing-library/react-native";
4
+ import { AnimationManager } from "../AnimationManager";
5
+ import {
6
+ NAV_ACTION_BACK,
7
+ NAV_ACTION_PUSH,
8
+ TransitionerComponent,
9
+ } from "../Transitioner";
10
+ import { act, render } from "@testing-library/react-native";
6
11
 
7
12
  jest.mock("../Scene", () => {
8
13
  const View = jest.requireActual("react-native").View;
@@ -40,6 +45,27 @@ const transitionerComponentProps = {
40
45
 
41
46
  jest.mock("uuid");
42
47
 
48
+ const sceneTransitionConfig = () => ({
49
+ push: {
50
+ duration: 0,
51
+ easing: jest.fn(),
52
+ from: { style: {} },
53
+ to: { style: {} },
54
+ },
55
+ back: {
56
+ duration: 0,
57
+ easing: jest.fn(),
58
+ from: { style: {} },
59
+ to: { style: {} },
60
+ },
61
+ });
62
+
63
+ const sceneFor = (route) => (
64
+ <View pathname={route}>
65
+ <Text>{route}</Text>
66
+ </View>
67
+ );
68
+
43
69
  describe("<TransitionerComponent />", () => {
44
70
  it("renders correctly", () => {
45
71
  const wrapper = render(
@@ -50,4 +76,59 @@ describe("<TransitionerComponent />", () => {
50
76
 
51
77
  expect(wrapper.toJSON()).toMatchSnapshot();
52
78
  });
79
+
80
+ it("removes both intermediate scenes when backing out to the tab root", () => {
81
+ jest
82
+ .spyOn(AnimationManager.prototype, "animate")
83
+ .mockImplementation((_, done) => done());
84
+
85
+ const ref = React.createRef();
86
+ const root = "/river/root";
87
+ const child = `${root}/river/child`;
88
+ const grandchild = `${child}/river/grandchild`;
89
+
90
+ const propsFor = (route, previousAction) => ({
91
+ navigator: {
92
+ previousAction,
93
+ currentRoute: route,
94
+ screenData: {},
95
+ },
96
+ transitionConfig: sceneTransitionConfig,
97
+ layoutData: {
98
+ isTablet: false,
99
+ isTabletPortrait: false,
100
+ },
101
+ children: sceneFor(route),
102
+ });
103
+
104
+ const { rerender } = render(
105
+ <TransitionerComponent ref={ref} {...propsFor(root, "REPLACE")} />
106
+ );
107
+
108
+ act(() => {
109
+ rerender(
110
+ <TransitionerComponent
111
+ ref={ref}
112
+ {...propsFor(child, NAV_ACTION_PUSH)}
113
+ />
114
+ );
115
+ });
116
+
117
+ act(() => {
118
+ rerender(
119
+ <TransitionerComponent
120
+ ref={ref}
121
+ {...propsFor(grandchild, NAV_ACTION_PUSH)}
122
+ />
123
+ );
124
+ });
125
+
126
+ act(() => {
127
+ rerender(
128
+ <TransitionerComponent ref={ref} {...propsFor(root, NAV_ACTION_BACK)} />
129
+ );
130
+ });
131
+
132
+ expect(ref.current.state.scenes.map((scene) => scene.key)).toEqual([root]);
133
+ });
53
134
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-ui-components",
3
- "version": "16.0.0-rc.100",
3
+ "version": "16.0.0-rc.101",
4
4
  "description": "Applicaster Zapp React Native ui components for the Quick Brick App",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,10 +28,10 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "16.0.0-rc.100",
32
- "@applicaster/zapp-react-native-bridge": "16.0.0-rc.100",
33
- "@applicaster/zapp-react-native-redux": "16.0.0-rc.100",
34
- "@applicaster/zapp-react-native-utils": "16.0.0-rc.100",
31
+ "@applicaster/applicaster-types": "16.0.0-rc.101",
32
+ "@applicaster/zapp-react-native-bridge": "16.0.0-rc.101",
33
+ "@applicaster/zapp-react-native-redux": "16.0.0-rc.101",
34
+ "@applicaster/zapp-react-native-utils": "16.0.0-rc.101",
35
35
  "fast-json-stable-stringify": "^2.1.0",
36
36
  "promise": "^8.3.0",
37
37
  "react-native-sortables": "1.7.1",