mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Test unauthanticated enable
This commit is contained in:
parent
bdfc2127d5
commit
8f2456aec4
@ -8,12 +8,10 @@ import createServer from '../../server'
|
||||
const factory = Factory()
|
||||
const neode = getNeode()
|
||||
const driver = getDriver()
|
||||
const categoryIds = ['cat9']
|
||||
|
||||
let query, mutate, authenticatedUser, variables, currentUser
|
||||
let createPostVariables
|
||||
let createCommentVariables
|
||||
|
||||
describe('moderate resources', () => {
|
||||
beforeAll(() => {
|
||||
authenticatedUser = undefined
|
||||
const { server } = createServer({
|
||||
@ -31,27 +29,13 @@ beforeAll(() => {
|
||||
|
||||
beforeEach(async () => {
|
||||
variables = {}
|
||||
currentUser = await factory.create('User', {
|
||||
id: 'current-user',
|
||||
name: 'TestUser',
|
||||
email: 'test@example.org',
|
||||
password: '1234',
|
||||
})
|
||||
|
||||
await Promise.all([
|
||||
neode.create('Category', {
|
||||
id: 'cat9',
|
||||
name: 'Democracy & Politics',
|
||||
icon: 'university',
|
||||
}),
|
||||
])
|
||||
authenticatedUser = null
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await factory.cleanDatabase()
|
||||
})
|
||||
describe('moderate resources', () => {
|
||||
|
||||
describe('disable', () => {
|
||||
const mutation = gql`
|
||||
mutation($id: ID!) {
|
||||
@ -66,9 +50,6 @@ describe('moderate resources', () => {
|
||||
}
|
||||
})
|
||||
describe('unauthenticated', () => {
|
||||
beforeEach(async () => {
|
||||
authenticatedUser = await currentUser.toJson()
|
||||
})
|
||||
it('throws authorization error', async () => {
|
||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||
errors: [{ message: 'Not Authorised!' }],
|
||||
@ -231,6 +212,20 @@ describe('moderate resources', () => {
|
||||
})
|
||||
|
||||
describe('enable', () => {
|
||||
const mutation = gql`
|
||||
mutation($id: ID!) {
|
||||
enable(id: $id)
|
||||
}
|
||||
`
|
||||
describe('unautenticated', () => {
|
||||
it('throws authorization error', async () => {
|
||||
variables = { id: 'sample-post-id' }
|
||||
await expect(mutate({ mutation, variables })).resolves.toMatchObject({
|
||||
errors: [{ message: 'Not Authorised!' }],
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// describe('authenticated', () => {
|
||||
// beforeEach(() => {
|
||||
// authenticateClient = setupAuthenticateClient({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user