Fix in news, first android notification service
This commit is contained in:
@@ -17,8 +17,13 @@ vi.mock('../server/utils/news.js', () => ({
|
||||
deleteNews: vi.fn()
|
||||
}))
|
||||
|
||||
vi.mock('../server/utils/push-notifications.js', () => ({
|
||||
sendNewNewsPush: vi.fn().mockResolvedValue({ sent: 1, skipped: false })
|
||||
}))
|
||||
|
||||
const authUtils = await import('../server/utils/auth.js')
|
||||
const newsUtils = await import('../server/utils/news.js')
|
||||
const pushUtils = await import('../server/utils/push-notifications.js')
|
||||
|
||||
import newsGetHandler from '../server/api/news.get.js'
|
||||
import newsPostHandler from '../server/api/news.post.js'
|
||||
@@ -111,6 +116,29 @@ describe('News API Endpoints', () => {
|
||||
expect(newsUtils.saveNews).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ title: 'Neue Info', content: 'Inhalt hier', isPublic: true })
|
||||
)
|
||||
expect(pushUtils.sendNewNewsPush).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ title: 'Neue Info', content: 'Inhalt hier', isPublic: true })
|
||||
)
|
||||
})
|
||||
|
||||
it('sendet keinen Push bei News-Update', async () => {
|
||||
const event = adminEvent()
|
||||
newsUtils.saveNews.mockResolvedValue(undefined)
|
||||
mockSuccessReadBody({ id: 'existing-news', title: 'Update', content: 'Inhalt' })
|
||||
|
||||
await newsPostHandler(event)
|
||||
|
||||
expect(pushUtils.sendNewNewsPush).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('sendet keinen Push bei versteckten News', async () => {
|
||||
const event = adminEvent()
|
||||
newsUtils.saveNews.mockResolvedValue(undefined)
|
||||
mockSuccessReadBody({ title: 'Intern', content: 'Inhalt', isHidden: true })
|
||||
|
||||
await newsPostHandler(event)
|
||||
|
||||
expect(pushUtils.sendNewNewsPush).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('setzt autor auf den angemeldeten Benutzer', async () => {
|
||||
|
||||
Reference in New Issue
Block a user