mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
[notifications] adopt strict zod types and extend test coverage (#36049)
* [notifications] adopt strict zod types and extend test coverage * [notifications] validate expires date via schema GitOrigin-RevId: 25dee0578ec443447e4c38a50a7e6c8b44831fe7
This commit is contained in:
@@ -104,18 +104,22 @@ describe('Notifications Controller', () => {
|
||||
modifiedCount: 1,
|
||||
upsertedCount: 0,
|
||||
})
|
||||
// addNotification's body schema is a strictObject that does not
|
||||
// include user_id (it's only ever read from params) -- drop it here
|
||||
// to match, same as every real caller (web's NotificationsHandler).
|
||||
const { user_id: _user_id, ...notification } = stubbedNotification[0]
|
||||
const req = {
|
||||
params: {
|
||||
user_id: userId,
|
||||
},
|
||||
body: stubbedNotification[0],
|
||||
body: notification,
|
||||
}
|
||||
await new Promise<void>(resolve => {
|
||||
controller.addNotification(req, {
|
||||
sendStatus: code => {
|
||||
expect(Notifications.addNotification).toHaveBeenCalledWith(
|
||||
userId,
|
||||
stubbedNotification[0]
|
||||
notification
|
||||
)
|
||||
expect(code).toBe(200)
|
||||
resolve()
|
||||
|
||||
Reference in New Issue
Block a user