raise backend unit test coverage, no promise all in notification spec

This commit is contained in:
Moriz Wahl 2023-11-02 19:16:41 +01:00
parent 23538fd849
commit ed5149c41e
2 changed files with 92 additions and 93 deletions

View File

@ -12,7 +12,7 @@ module.exports = {
], ],
coverageThreshold: { coverageThreshold: {
global: { global: {
lines: 67, lines: 72,
}, },
}, },
testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'], testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'],

View File

@ -56,98 +56,97 @@ describe('given some notifications', () => {
Factory.build('user', { id: 'neighbor' }), Factory.build('user', { id: 'neighbor' }),
Factory.build('category', { id: 'cat1' }), Factory.build('category', { id: 'cat1' }),
]) ])
const [post1, post2, post3] = await Promise.all([ const post1 = await Factory.build(
Factory.build('post', { id: 'p1', content: 'Not for you' }, { author, categoryIds }), 'post',
Factory.build( { id: 'p1', content: 'Not for you' },
'post', { author, categoryIds },
{ )
id: 'p2', const post2 = await Factory.build(
content: 'Already seen post mention', 'post',
}, {
{ id: 'p2',
author, content: 'Already seen post mention',
categoryIds, },
}, {
), author,
Factory.build( categoryIds,
'post', },
{ )
id: 'p3', const post3 = await Factory.build(
content: 'You have been mentioned in a post', 'post',
}, {
{ id: 'p3',
author, content: 'You have been mentioned in a post',
categoryIds, },
}, {
), author,
]) categoryIds,
const [comment1, comment2, comment3] = await Promise.all([ },
Factory.build( )
'comment', const comment1 = await Factory.build(
{ 'comment',
id: 'c1', {
content: 'You have seen this comment mentioning already', id: 'c1',
}, content: 'You have seen this comment mentioning already',
{ },
author, {
postId: 'p3', author,
}, postId: 'p3',
), },
Factory.build( )
'comment', const comment2 = await Factory.build(
{ 'comment',
id: 'c2', {
content: 'You have been mentioned in a comment', id: 'c2',
}, content: 'You have been mentioned in a comment',
{ },
author, {
postId: 'p3', author,
}, postId: 'p3',
), },
Factory.build( )
'comment', const comment3 = await Factory.build(
{ 'comment',
id: 'c3', {
content: 'Somebody else was mentioned in a comment', id: 'c3',
}, content: 'Somebody else was mentioned in a comment',
{ },
author, {
postId: 'p3', author,
}, postId: 'p3',
), },
]) )
await Promise.all([
post1.relateTo(neighbor, 'notified', { await post1.relateTo(neighbor, 'notified', {
createdAt: '2019-08-29T17:33:48.651Z', createdAt: '2019-08-29T17:33:48.651Z',
read: false, read: false,
reason: 'mentioned_in_post', reason: 'mentioned_in_post',
}), })
post2.relateTo(user, 'notified', { await post2.relateTo(user, 'notified', {
createdAt: '2019-08-30T17:33:48.651Z', createdAt: '2019-08-30T17:33:48.651Z',
read: true, read: true,
reason: 'mentioned_in_post', reason: 'mentioned_in_post',
}), })
post3.relateTo(user, 'notified', { await post3.relateTo(user, 'notified', {
createdAt: '2019-08-31T17:33:48.651Z', createdAt: '2019-08-31T17:33:48.651Z',
read: false, read: false,
reason: 'mentioned_in_post', reason: 'mentioned_in_post',
}), })
comment1.relateTo(user, 'notified', { await comment1.relateTo(user, 'notified', {
createdAt: '2019-08-30T15:33:48.651Z', createdAt: '2019-08-30T15:33:48.651Z',
read: true, read: true,
reason: 'mentioned_in_comment', reason: 'mentioned_in_comment',
}), })
comment2.relateTo(user, 'notified', { await comment2.relateTo(user, 'notified', {
createdAt: '2019-08-30T19:33:48.651Z', createdAt: '2019-08-30T19:33:48.651Z',
read: false, read: false,
reason: 'mentioned_in_comment', reason: 'mentioned_in_comment',
}), })
comment3.relateTo(neighbor, 'notified', { await comment3.relateTo(neighbor, 'notified', {
createdAt: '2019-09-01T17:33:48.651Z', createdAt: '2019-09-01T17:33:48.651Z',
read: false, read: false,
reason: 'mentioned_in_comment', reason: 'mentioned_in_comment',
}), })
])
}) })
describe('notifications', () => { describe('notifications', () => {