mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Add backend tests for custom queries
This commit is contained in:
parent
9613250710
commit
d795ee50a9
@ -443,7 +443,6 @@ describe('emotions', () => {
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
describe('unauthenticated', () => {
|
||||
it('throws authorization error', async () => {
|
||||
client = new GraphQLClient(host)
|
||||
@ -601,4 +600,55 @@ describe('emotions', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('posts emotions count', () => {
|
||||
let headers
|
||||
let postsEmotionsCountByEmotionVariables
|
||||
let postsEmotionsCountByCurrentUserVariables
|
||||
|
||||
const postsEmotionsCountByEmotionQuery = `
|
||||
query($postId: ID!, $data: _EMOTEDInput!) {
|
||||
postsEmotionsCountByEmotion(postId: $postId, data: $data)
|
||||
}
|
||||
`
|
||||
|
||||
const postsEmotionsCountByCurrentUserQuery = `
|
||||
query($postId: ID!) {
|
||||
postsEmotionsCountByCurrentUser(postId: $postId)
|
||||
}
|
||||
`
|
||||
beforeEach(async () => {
|
||||
headers = await login(authorParams)
|
||||
client = new GraphQLClient(host, { headers })
|
||||
await factory.emote({
|
||||
from: authorParams.id,
|
||||
to: 'p1376',
|
||||
data: 'cry',
|
||||
})
|
||||
postsEmotionsCountByEmotionVariables = {
|
||||
postId: 'p1376',
|
||||
data: { emotion: 'cry' },
|
||||
}
|
||||
postsEmotionsCountByCurrentUserVariables = { postId: 'p1376' }
|
||||
})
|
||||
|
||||
describe('postsEmotionsCountByEmotion', () => {
|
||||
it("returns a post's emotions count", async () => {
|
||||
await expect(
|
||||
client.request(postsEmotionsCountByEmotionQuery, postsEmotionsCountByEmotionVariables),
|
||||
).resolves.toEqual({ postsEmotionsCountByEmotion: 1 })
|
||||
})
|
||||
})
|
||||
|
||||
describe('postsEmotionsCountByEmotion', () => {
|
||||
it("returns a currentUser's emotions on a post", async () => {
|
||||
await expect(
|
||||
client.request(
|
||||
postsEmotionsCountByCurrentUserQuery,
|
||||
postsEmotionsCountByCurrentUserVariables,
|
||||
),
|
||||
).resolves.toEqual({ postsEmotionsCountByCurrentUser: ['cry'] })
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user