mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
fix lint: tests and lint ok
This commit is contained in:
parent
9d5c192869
commit
d2a43cecd7
@ -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')
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
it('returns the count of all users', async() => {
|
||||
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
|
||||
data: { statistics: { countUsers: 6 } },
|
||||
errors: undefined,
|
||||
})
|
||||
})
|
||||
describe('countUsers', () => {
|
||||
beforeEach(async () => {
|
||||
await Promise.all(
|
||||
[...Array(6).keys()].map(() => {
|
||||
return Factory.build('user')
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
describe('countPosts', () => {
|
||||
beforeEach(async() => {
|
||||
await Promise.all(
|
||||
[...Array(3).keys()].map(() => {
|
||||
return Factory.build('post')
|
||||
}),
|
||||
)
|
||||
})
|
||||
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 posts', async() => {
|
||||
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
|
||||
data: { statistics: { countPosts: 3 } },
|
||||
errors: undefined,
|
||||
})
|
||||
})
|
||||
describe('countPosts', () => {
|
||||
beforeEach(async () => {
|
||||
await Promise.all(
|
||||
[...Array(3).keys()].map(() => {
|
||||
return Factory.build('post')
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
describe('countComments', () => {
|
||||
beforeEach(async() => {
|
||||
await Promise.all(
|
||||
[...Array(2).keys()].map(() => {
|
||||
return Factory.build('comment')
|
||||
}),
|
||||
)
|
||||
})
|
||||
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 comments', async() => {
|
||||
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
|
||||
data: { statistics: { countComments: 2 } },
|
||||
errors: undefined,
|
||||
})
|
||||
})
|
||||
describe('countComments', () => {
|
||||
beforeEach(async () => {
|
||||
await Promise.all(
|
||||
[...Array(2).keys()].map(() => {
|
||||
return Factory.build('comment')
|
||||
}),
|
||||
)
|
||||
})
|
||||
|
||||
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 comments', async () => {
|
||||
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
|
||||
data: { statistics: { countComments: 2 } },
|
||||
errors: undefined,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('returns the count of all follows', async() => {
|
||||
await expect(query({ query: statisticsQuery })).resolves.toMatchObject({
|
||||
data: { statistics: { countFollows: 1 } },
|
||||
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('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 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'),
|
||||
])
|
||||
})
|
||||
|
||||
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
Loading…
x
Reference in New Issue
Block a user