Merge pull request #6814 from Ocelot-Social-Community/more-coverage-backend

feat(backend): coverage backend to 90%
This commit is contained in:
Moriz Wahl 2023-11-03 15:20:27 +01:00 committed by GitHub
commit dadc085e2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 93 additions and 94 deletions

View File

@ -8,11 +8,11 @@ module.exports = {
'!**/test/**', '!**/test/**',
'!**/build/**', '!**/build/**',
'!**/src/**/?(*.)+(spec|test).ts?(x)', '!**/src/**/?(*.)+(spec|test).ts?(x)',
'!**/src/db/migrations/**' '!**/src/db/**'
], ],
coverageThreshold: { coverageThreshold: {
global: { global: {
lines: 67, lines: 90,
}, },
}, },
testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'], testMatch: ['**/src/**/?(*.)+(spec|test).ts?(x)'],

View File

@ -56,9 +56,12 @@ 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' },
{ author, categoryIds },
)
const post2 = await Factory.build(
'post', 'post',
{ {
id: 'p2', id: 'p2',
@ -68,8 +71,8 @@ describe('given some notifications', () => {
author, author,
categoryIds, categoryIds,
}, },
), )
Factory.build( const post3 = await Factory.build(
'post', 'post',
{ {
id: 'p3', id: 'p3',
@ -79,10 +82,8 @@ describe('given some notifications', () => {
author, author,
categoryIds, categoryIds,
}, },
), )
]) const comment1 = await Factory.build(
const [comment1, comment2, comment3] = await Promise.all([
Factory.build(
'comment', 'comment',
{ {
id: 'c1', id: 'c1',
@ -92,8 +93,8 @@ describe('given some notifications', () => {
author, author,
postId: 'p3', postId: 'p3',
}, },
), )
Factory.build( const comment2 = await Factory.build(
'comment', 'comment',
{ {
id: 'c2', id: 'c2',
@ -103,8 +104,8 @@ describe('given some notifications', () => {
author, author,
postId: 'p3', postId: 'p3',
}, },
), )
Factory.build( const comment3 = await Factory.build(
'comment', 'comment',
{ {
id: 'c3', id: 'c3',
@ -114,40 +115,38 @@ describe('given some notifications', () => {
author, author,
postId: 'p3', postId: 'p3',
}, },
), )
])
await Promise.all([ await post1.relateTo(neighbor, 'notified', {
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', () => {