Skip to content

Commit c93bc28

Browse files
committed
🚨 Strengthen redirect assertions to validate status and location (#2446)
1 parent a636c4b commit c93bc28

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/test/lib/utils/authorship.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('ensureSessionOrRedirect', () => {
4949
},
5050
} as unknown as App.Locals;
5151

52-
await expect(ensureSessionOrRedirect(mockLocals)).rejects.toThrow();
52+
await expect(ensureSessionOrRedirect(mockLocals)).rejects.toThrow(/Redirect \d{3} \/login/);
5353
});
5454
});
5555

@@ -74,7 +74,7 @@ describe('getLoggedInUser', () => {
7474
},
7575
} as unknown as App.Locals;
7676

77-
await expect(getLoggedInUser(mockLocals)).rejects.toThrow();
77+
await expect(getLoggedInUser(mockLocals)).rejects.toThrow(/Redirect \d{3} \/login/);
7878
});
7979

8080
test('expect to redirect when session exists but no user', async () => {
@@ -85,7 +85,7 @@ describe('getLoggedInUser', () => {
8585
user: null,
8686
} as unknown as App.Locals;
8787

88-
await expect(getLoggedInUser(mockLocals)).rejects.toThrow();
88+
await expect(getLoggedInUser(mockLocals)).rejects.toThrow(/Redirect \d{3} \/login/);
8989
});
9090
});
9191

0 commit comments

Comments
 (0)