forked from solidcouch/simple-email-notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatus.spec.ts
64 lines (53 loc) · 1.85 KB
/
status.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { expect } from 'chai'
import fetch from 'cross-fetch'
import { describe } from 'mocha'
import { baseUrl } from '../config'
import { verifyEmail } from './helpers'
import {
authenticatedFetch,
authenticatedFetch3,
otherAuthenticatedFetch,
otherPerson,
person,
person3,
} from './testSetup.spec'
const email = 'email@example.com'
describe('get info about integrations of a person with GET /status/:webId', () => {
beforeEach(async () => {
await verifyEmail({ email, authenticatedFetch, person })
})
it('[not authenticated] should fail with 401', async () => {
const response = await fetch(
`${baseUrl}/status/${encodeURIComponent(person.webId)}`,
)
expect(response.status).to.equal(401)
})
it('[authenticated person not from group] should fail with 403', async () => {
const response = await otherAuthenticatedFetch(
`${baseUrl}/status/${encodeURIComponent(person.webId)}`,
)
expect(response.status).to.equal(403)
})
it('[requested person not from group] should fail with 400', async () => {
const response = await authenticatedFetch(
`${baseUrl}/status/${encodeURIComponent(otherPerson.webId)}`,
)
expect(response.status).to.equal(400)
})
it('should say that email of user is verified', async () => {
const response = await authenticatedFetch3(
`${baseUrl}/status/${encodeURIComponent(person.webId)}`,
)
expect(response.status).to.equal(200)
const body = await response.json()
expect(body).to.deep.equal({ emailVerified: true })
})
it('should say that email of user is not verified', async () => {
const response = await authenticatedFetch(
`${baseUrl}/status/${encodeURIComponent(person3.webId)}`,
)
expect(response.status).to.equal(200)
const body = await response.json()
expect(body).to.deep.equal({ emailVerified: false })
})
})