mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Merge remote-tracking branch 'origin/master' into editor
This commit is contained in:
commit
c86658729e
@ -62,7 +62,7 @@
|
||||
"passport": "~0.4.0",
|
||||
"passport-jwt": "~4.0.0",
|
||||
"sanitize-html": "~1.20.0",
|
||||
"slug": "~0.9.3",
|
||||
"slug": "~1.0.0",
|
||||
"trunc-html": "~1.1.2",
|
||||
"wait-on": "~3.2.0"
|
||||
},
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import Factory from './seed/factories'
|
||||
import { GraphQLClient, request } from 'graphql-request'
|
||||
import jwt from 'jsonwebtoken'
|
||||
import { host, login } from './jest/helpers'
|
||||
import { GraphQLClient, request } from 'graphql-request'
|
||||
|
||||
const factory = Factory()
|
||||
|
||||
@ -119,3 +119,66 @@ describe('CreatePost', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('report', () => {
|
||||
beforeEach(async () => {
|
||||
await factory.create('user', {
|
||||
email: 'test@example.org',
|
||||
password: '1234'
|
||||
})
|
||||
await factory.create('user', {
|
||||
id: 'u2',
|
||||
name: 'abusive-user',
|
||||
role: 'user',
|
||||
email: 'abusive-user@example.org'
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await factory.cleanDatabase()
|
||||
})
|
||||
|
||||
describe('unauthenticated', () => {
|
||||
let client
|
||||
it('throws authorization error', async () => {
|
||||
client = new GraphQLClient(host)
|
||||
await expect(
|
||||
client.request(`mutation {
|
||||
report(
|
||||
description: "I don't like this user",
|
||||
resource: {
|
||||
id: "u2",
|
||||
type: user
|
||||
}
|
||||
) { id, createdAt }
|
||||
}`)
|
||||
).rejects.toThrow('Not Authorised')
|
||||
})
|
||||
|
||||
describe('authenticated', () => {
|
||||
let headers
|
||||
let response
|
||||
beforeEach(async () => {
|
||||
headers = await login({ email: 'test@example.org', password: '1234' })
|
||||
client = new GraphQLClient(host, { headers })
|
||||
response = await client.request(`mutation {
|
||||
report(
|
||||
description: "I don't like this user",
|
||||
resource: {
|
||||
id: "u2",
|
||||
type: user
|
||||
}
|
||||
) { id, createdAt }
|
||||
}`,
|
||||
{ headers }
|
||||
)
|
||||
})
|
||||
it('creates a report', () => {
|
||||
let { id, createdAt } = response.report
|
||||
expect(response).toEqual({
|
||||
report: { id, createdAt }
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@ -6232,10 +6232,10 @@ slice-ansi@2.0.0:
|
||||
astral-regex "^1.0.0"
|
||||
is-fullwidth-code-point "^2.0.0"
|
||||
|
||||
slug@~0.9.3:
|
||||
version "0.9.3"
|
||||
resolved "https://registry.yarnpkg.com/slug/-/slug-0.9.3.tgz#8c9c773d79367c0188733316cf49fd2b8db40f6a"
|
||||
integrity sha512-DddSQQnUdAofjFOKRT+zsMNrdzdte04G5DUA+NeaUJlPAqR1bWQ22qVfayRxHFiRGR3bUV0wt5VSj4849pGKSw==
|
||||
slug@~1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/slug/-/slug-1.0.0.tgz#503be07b150226a42abf7a9c52d345e6b163fea8"
|
||||
integrity sha512-m3uDtlWbJmYiwxVU1+jIvYEgfYmvtjWE/KtM6IfNzuRyHv+9RMukxMVph1ra+/499fVOKgTcK/8s2gLrYoP+BA==
|
||||
dependencies:
|
||||
unicode ">= 0.3.1"
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user