test(mobile): assert route-slice anchors are unique so pins cannot slice the wrong region

This commit is contained in:
Brennan Benson
2026-07-29 19:30:06 -07:00
parent 27b6b72178
commit 8db1d41fda
@@ -11,6 +11,8 @@ const sessionRouteSource = readFileSync(
function routeSlice(anchorStart: string, anchorEnd: string): string {
const start = sessionRouteSource.indexOf(anchorStart)
expect(start).toBeGreaterThanOrEqual(0)
// Why: a duplicated start anchor would silently slice the wrong region.
expect(sessionRouteSource.indexOf(anchorStart, start + 1)).toBe(-1)
const end = sessionRouteSource.indexOf(anchorEnd, start)
expect(end).toBeGreaterThan(start)
return sessionRouteSource.slice(start, end + anchorEnd.length)