mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Refactor tests to dry out, search for by comment id
This commit is contained in:
parent
70aa77bd2e
commit
6b0c1312f1
@ -137,17 +137,19 @@ describe('users', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
describe('attempting to delete my own account', () => {
|
describe('attempting to delete my own account', () => {
|
||||||
|
const commentQueryVariables = { id: 'c155' }
|
||||||
|
const postQueryVariables = { id: 'p139' }
|
||||||
const commentQuery = gql`
|
const commentQuery = gql`
|
||||||
query($content: String) {
|
query($id: ID) {
|
||||||
Comment(content: $content) {
|
Comment(id: $id) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
const postQuery = gql`
|
const postQuery = gql`
|
||||||
query($content: String) {
|
query($id: ID) {
|
||||||
Post(content: $content) {
|
Post(id: $id) {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,10 +185,7 @@ describe('users', () => {
|
|||||||
describe("doesn't delete a user's", () => {
|
describe("doesn't delete a user's", () => {
|
||||||
it('comments by default', async () => {
|
it('comments by default', async () => {
|
||||||
await client.request(deleteUserMutation, deleteUserVariables)
|
await client.request(deleteUserMutation, deleteUserVariables)
|
||||||
const commentQueryVariablesByContent = {
|
const { Comment } = await client.request(commentQuery, commentQueryVariables)
|
||||||
content: 'Comment by user u343',
|
|
||||||
}
|
|
||||||
const { Comment } = await client.request(commentQuery, commentQueryVariablesByContent)
|
|
||||||
expect(Comment).toEqual([
|
expect(Comment).toEqual([
|
||||||
{
|
{
|
||||||
id: 'c155',
|
id: 'c155',
|
||||||
@ -196,10 +195,7 @@ describe('users', () => {
|
|||||||
|
|
||||||
it('posts by default', async () => {
|
it('posts by default', async () => {
|
||||||
await client.request(deleteUserMutation, deleteUserVariables)
|
await client.request(deleteUserMutation, deleteUserVariables)
|
||||||
const postQueryVariablesByContent = {
|
const { Post } = await client.request(postQuery, postQueryVariables)
|
||||||
content: 'Post by user u343',
|
|
||||||
}
|
|
||||||
const { Post } = await client.request(postQuery, postQueryVariablesByContent)
|
|
||||||
expect(Post).toEqual([
|
expect(Post).toEqual([
|
||||||
{
|
{
|
||||||
id: 'p139',
|
id: 'p139',
|
||||||
@ -212,34 +208,22 @@ describe('users', () => {
|
|||||||
it('posts on request', async () => {
|
it('posts on request', async () => {
|
||||||
deleteUserVariables = { id: 'u343', resource: ['Post'] }
|
deleteUserVariables = { id: 'u343', resource: ['Post'] }
|
||||||
await client.request(deleteUserMutation, deleteUserVariables)
|
await client.request(deleteUserMutation, deleteUserVariables)
|
||||||
const postQueryVariablesByContent = {
|
const { Post } = await client.request(postQuery, postQueryVariables)
|
||||||
content: 'Post by user u343',
|
|
||||||
}
|
|
||||||
const { Post } = await client.request(postQuery, postQueryVariablesByContent)
|
|
||||||
expect(Post).toEqual([])
|
expect(Post).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('comments on request', async () => {
|
it('comments on request', async () => {
|
||||||
deleteUserVariables = { id: 'u343', resource: ['Comment'] }
|
deleteUserVariables = { id: 'u343', resource: ['Comment'] }
|
||||||
await client.request(deleteUserMutation, deleteUserVariables)
|
await client.request(deleteUserMutation, deleteUserVariables)
|
||||||
const commentQueryVariablesByContent = {
|
const { Comment } = await client.request(commentQuery, commentQueryVariables)
|
||||||
content: 'Comment by user u343',
|
|
||||||
}
|
|
||||||
const { Comment } = await client.request(commentQuery, commentQueryVariablesByContent)
|
|
||||||
expect(Comment).toEqual([])
|
expect(Comment).toEqual([])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('posts and comments on request', async () => {
|
it('posts and comments on request', async () => {
|
||||||
deleteUserVariables = { id: 'u343', resource: ['Post', 'Comment'] }
|
deleteUserVariables = { id: 'u343', resource: ['Post', 'Comment'] }
|
||||||
await client.request(deleteUserMutation, deleteUserVariables)
|
await client.request(deleteUserMutation, deleteUserVariables)
|
||||||
const postQueryVariablesByContent = {
|
const { Post } = await client.request(postQuery, postQueryVariables)
|
||||||
content: 'Post by user u343',
|
const { Comment } = await client.request(commentQuery, commentQueryVariables)
|
||||||
}
|
|
||||||
const commentQueryVariablesByContent = {
|
|
||||||
content: 'Comment by user u343',
|
|
||||||
}
|
|
||||||
const { Post } = await client.request(postQuery, postQueryVariablesByContent)
|
|
||||||
const { Comment } = await client.request(commentQuery, commentQueryVariablesByContent)
|
|
||||||
expect(Post).toEqual([])
|
expect(Post).toEqual([])
|
||||||
expect(Comment).toEqual([])
|
expect(Comment).toEqual([])
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user