test(worker): lib/api + app/nav — fill gaps + lifecycle test

This commit is contained in:
Bas van Rossem
2026-07-23 14:15:48 +02:00
parent 32bdaa3e31
commit e174c29a77
7 changed files with 233 additions and 0 deletions

View File

@@ -42,4 +42,20 @@ describe('App', () => {
expect(tabbar.getByText('Geschiedenis')).toBeInTheDocument();
expect(tabbar.getByText('Account')).toBeInTheDocument();
});
it('lifecycle: unauthenticated renders Login (no nav); authenticated renders Stopwatch under the tab bar', () => {
// No token -> the Login screen, and no tab bar navigation.
clearToken();
const { unmount } = renderApp();
expect(screen.getByText('E-mailadres')).toBeInTheDocument();
expect(screen.queryByRole('navigation')).not.toBeInTheDocument();
unmount();
// Token present -> the Stopwatch screen is mounted at "/" beside the tab bar.
setToken('tok');
renderApp();
expect(screen.getByText('Type zool')).toBeInTheDocument();
expect(within(screen.getByRole('navigation')).getByText('Stopwatch')).toBeInTheDocument();
expect(screen.queryByText('E-mailadres')).not.toBeInTheDocument();
});
});