| ... | ... | @@ -143,21 +143,41 @@ describe("v5 stack handoff", () => { |
| 143 | 143 | }); |
| 144 | 144 | it("still retains an unfinished JS pop beside a completed native pop", () => { |
| 145 | 145 | expect(reconcileStackScreens([home, thread, files], [home], new Set([files.key]))).toEqual([ |
| 146 | | thread, |
| 147 | 146 | home, |
| 147 | thread, |
| 148 | 148 | ]); |
| 149 | 149 | }); |
| 150 | 150 | it("retains removed native screens through a pop followed immediately by a push", () => { |
| 151 | 151 | const popped = reconcileStackScreens([home, thread, files], [home, thread]); |
| 152 | 152 | const next = { ...files, key: "new-files" }; |
| 153 | 153 | const screens = reconcileStackScreens(popped, [home, thread, next]); |
| 154 | | expect(screens.map((route) => route.key)).toEqual(["files", "home", "thread", "new-files"]); |
| 154 | expect(screens.map((route) => route.key)).toEqual(["home", "thread", "files", "new-files"]); |
| 155 | 155 | expect(screens.filter((route) => [home, thread, next].includes(route))).toEqual([ |
| 156 | 156 | home, |
| 157 | 157 | thread, |
| 158 | 158 | next, |
| 159 | 159 | ]); |
| 160 | | expect(screens[0]).toBe(files); |
| 160 | expect(screens[2]).toBe(files); |
| 161 | }); |
| 162 | it("keeps the root and outgoing settings page in place until the JS pop finishes", () => { |
| 163 | const environments = { ...files, key: "environments", name: "SettingsEnvironments" }; |
| 164 | const popped = reconcileStackScreens([settings, environments], [settings]); |
| 165 | expect(popped).toEqual([settings, environments]); |
| 166 | expect(reconcileStackScreens(popped, [settings])).toEqual(popped); |
| 167 | const next = { ...environments, key: "next-environments" }; |
| 168 | expect(reconcileStackScreens(popped, [settings, next])).toEqual([settings, environments, next]); |
| 169 | expect(reconcileStackScreens(popped, [settings], new Set([environments.key]))).toEqual([ |
| 170 | settings, |
| 171 | ]); |
| 172 | }); |
| 173 | it("retains a multi-page pop in order without changing the active router order", () => { |
| 174 | const replacement = { ...thread, key: "replacement" }; |
| 175 | const screens = reconcileStackScreens([home, thread, files], [home, replacement]); |
| 176 | expect(screens).toEqual([home, thread, files, replacement]); |
| 177 | expect(screens.filter((route) => route === home || route === replacement)).toEqual([ |
| 178 | home, |
| 179 | replacement, |
| 180 | ]); |
| 161 | 181 | }); |
| 162 | 182 | it("updates params without retaining duplicate copies of the same screen", () => { |
| 163 | 183 | const updated = { ...thread, params: { threadId: "another-thread" } }; |