mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Merge pull request #1772 from Human-Connection/1706_refactor-shout-spec
Fix failing test
This commit is contained in:
commit
5f475e9aef
@ -46,8 +46,23 @@ describe('shout and unshout posts', () => {
|
|||||||
mutate = createTestClient(server).mutate
|
mutate = createTestClient(server).mutate
|
||||||
query = createTestClient(server).query
|
query = createTestClient(server).query
|
||||||
})
|
})
|
||||||
afterEach(() => {
|
beforeEach(async () => {
|
||||||
factory.cleanDatabase()
|
currentUser = await factory.create('User', {
|
||||||
|
id: 'current-user-id',
|
||||||
|
name: 'Current User',
|
||||||
|
email: 'current.user@example.org',
|
||||||
|
password: '1234',
|
||||||
|
})
|
||||||
|
|
||||||
|
postAuthor = await factory.create('User', {
|
||||||
|
id: 'id-of-another-user',
|
||||||
|
name: 'Another User',
|
||||||
|
email: 'another.user@example.org',
|
||||||
|
password: '1234',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
afterEach(async () => {
|
||||||
|
await factory.cleanDatabase()
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('shout', () => {
|
describe('shout', () => {
|
||||||
@ -62,19 +77,6 @@ describe('shout and unshout posts', () => {
|
|||||||
})
|
})
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await factory.create('User', {
|
|
||||||
id: 'current-user-id',
|
|
||||||
name: 'Current User',
|
|
||||||
email: 'current.user@example.org',
|
|
||||||
password: '1234',
|
|
||||||
})
|
|
||||||
|
|
||||||
postAuthor = await factory.create('User', {
|
|
||||||
id: 'post-author-id',
|
|
||||||
name: 'Post Author',
|
|
||||||
email: 'post.author@example.org',
|
|
||||||
password: '1234',
|
|
||||||
})
|
|
||||||
authenticatedUser = await currentUser.toJson()
|
authenticatedUser = await currentUser.toJson()
|
||||||
await factory.create('Post', {
|
await factory.create('Post', {
|
||||||
name: 'Other user post',
|
name: 'Other user post',
|
||||||
@ -89,7 +91,7 @@ describe('shout and unshout posts', () => {
|
|||||||
variables = {}
|
variables = {}
|
||||||
})
|
})
|
||||||
|
|
||||||
it("another user's post", async () => {
|
it("can shout another user's post", async () => {
|
||||||
variables = { id: 'another-user-post-id' }
|
variables = { id: 'another-user-post-id' }
|
||||||
await expect(mutate({ mutation: mutationShoutPost, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: mutationShoutPost, variables })).resolves.toMatchObject({
|
||||||
data: { shout: true },
|
data: { shout: true },
|
||||||
@ -100,7 +102,7 @@ describe('shout and unshout posts', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('my own post', async () => {
|
it('can not shout my own post', async () => {
|
||||||
variables = { id: 'current-user-post-id' }
|
variables = { id: 'current-user-post-id' }
|
||||||
await expect(mutate({ mutation: mutationShoutPost, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: mutationShoutPost, variables })).resolves.toMatchObject({
|
||||||
data: { shout: false },
|
data: { shout: false },
|
||||||
@ -125,19 +127,6 @@ describe('shout and unshout posts', () => {
|
|||||||
|
|
||||||
describe('authenticated', () => {
|
describe('authenticated', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
currentUser = await factory.create('User', {
|
|
||||||
id: 'current-user-id',
|
|
||||||
name: 'Current User',
|
|
||||||
email: 'current.user@example.org',
|
|
||||||
password: '1234',
|
|
||||||
})
|
|
||||||
|
|
||||||
postAuthor = await factory.create('User', {
|
|
||||||
id: 'id-of-another-user',
|
|
||||||
name: 'Another User',
|
|
||||||
email: 'another.user@example.org',
|
|
||||||
password: '1234',
|
|
||||||
})
|
|
||||||
authenticatedUser = await currentUser.toJson()
|
authenticatedUser = await currentUser.toJson()
|
||||||
await factory.create('Post', {
|
await factory.create('Post', {
|
||||||
name: 'Posted By Another User',
|
name: 'Posted By Another User',
|
||||||
@ -148,10 +137,9 @@ describe('shout and unshout posts', () => {
|
|||||||
mutation: mutationShoutPost,
|
mutation: mutationShoutPost,
|
||||||
variables: { id: 'posted-by-another-user' },
|
variables: { id: 'posted-by-another-user' },
|
||||||
})
|
})
|
||||||
variables = {}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("another user's post", async () => {
|
it("can unshout another user's post", async () => {
|
||||||
variables = { id: 'posted-by-another-user' }
|
variables = { id: 'posted-by-another-user' }
|
||||||
await expect(mutate({ mutation: mutationUnshoutPost, variables })).resolves.toMatchObject({
|
await expect(mutate({ mutation: mutationUnshoutPost, variables })).resolves.toMatchObject({
|
||||||
data: { unshout: true },
|
data: { unshout: true },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user