tests user.spec.js tests once clean once broken always alternating

This commit is contained in:
ogerly 2020-07-30 11:45:51 +02:00
parent 7b48339e18
commit 9d5c192869
2 changed files with 628 additions and 934 deletions

View File

@ -8,7 +8,7 @@ let query, authenticatedUser
const instance = getNeode()
const driver = getDriver()
const statisticsQuery = gql`
const statisticsQuery = gql `
query {
statistics {
countUsers
@ -22,118 +22,118 @@ const statisticsQuery = gql`
}
`
beforeAll(() => {
authenticatedUser = undefined
const { server } = createServer({
context: () => {
return {
driver,
neode: instance,
user: authenticatedUser,
}
},
})
query = createTestClient(server).query
authenticatedUser = undefined
const { server } = createServer({
context: () => {
return {
driver,
neode: instance,
user: authenticatedUser,
}
},
})
query = createTestClient(server).query
})
afterEach(async () => {
await cleanDatabase()
afterEach(async() => {
await cleanDatabase()
})
describe('statistics', () => {
describe('countUsers', () => {
beforeEach(async () => {
await Promise.all(
[...Array(6).keys()].map(() => {
return Factory.build('user')
}),
)
describe('countUsers', () => {
beforeEach(async() => {
await Promise.all(
[...Array(6).keys()].map(() => {
return Factory.build('user')
}),
)
})
it('returns the count of all users', async() => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countUsers: 6 } },
errors: undefined,
})
})
})
it('returns the count of all users', async () => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countUsers: 6 } },
errors: undefined,
})
})
})
describe('countPosts', () => {
beforeEach(async() => {
await Promise.all(
[...Array(3).keys()].map(() => {
return Factory.build('post')
}),
)
})
describe('countPosts', () => {
beforeEach(async () => {
await Promise.all(
[...Array(3).keys()].map(() => {
return Factory.build('post')
}),
)
it('returns the count of all posts', async() => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countPosts: 3 } },
errors: undefined,
})
})
})
it('returns the count of all posts', async () => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countPosts: 3 } },
errors: undefined,
})
})
})
describe('countComments', () => {
beforeEach(async() => {
await Promise.all(
[...Array(2).keys()].map(() => {
return Factory.build('comment')
}),
)
})
describe('countComments', () => {
beforeEach(async () => {
await Promise.all(
[...Array(2).keys()].map(() => {
return Factory.build('comment')
}),
)
it('returns the count of all comments', async() => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countComments: 2 } },
errors: undefined,
})
})
})
it('returns the count of all comments', async () => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countComments: 2 } },
errors: undefined,
})
})
})
describe('countFollows', () => {
let users
beforeEach(async() => {
users = await Promise.all(
[...Array(2).keys()].map(() => {
return Factory.build('user')
}),
)
await users[0].relateTo(users[1], 'following')
})
describe('countFollows', () => {
let users
beforeEach(async () => {
users = await Promise.all(
[...Array(2).keys()].map(() => {
return Factory.build('user')
}),
)
await users[0].relateTo(users[1], 'following')
it('returns the count of all follows', async() => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countFollows: 1 } },
errors: undefined,
})
})
})
it('returns the count of all follows', async () => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countFollows: 1 } },
errors: undefined,
})
})
})
describe('countShouts', () => {
let users, posts
beforeEach(async() => {
users = await Promise.all(
[...Array(2).keys()].map(() => {
return Factory.build('user')
}),
)
posts = await Promise.all(
[...Array(3).keys()].map(() => {
return Factory.build('post')
}),
)
await Promise.all([
users[0].relateTo(posts[1], 'shouted'),
users[1].relateTo(posts[0], 'shouted'),
])
})
describe('countShouts', () => {
let users, posts
beforeEach(async () => {
users = await Promise.all(
[...Array(2).keys()].map(() => {
return Factory.build('user')
}),
)
posts = await Promise.all(
[...Array(3).keys()].map(() => {
return Factory.build('post')
}),
)
await Promise.all([
users[0].relateTo(posts[1], 'shouted'),
users[1].relateTo(posts[0], 'shouted'),
])
it('returns the count of all shouts', async() => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countShouts: 2 } },
errors: undefined,
})
})
})
it('returns the count of all shouts', async () => {
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
data: { statistics: { countShouts: 2 } },
errors: undefined,
})
})
})
})
})

File diff suppressed because it is too large Load Diff