test(worker): lib/api + app/nav — fill gaps + lifecycle test
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user