-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.integration.spec.js
More file actions
46 lines (42 loc) · 1.29 KB
/
app.integration.spec.js
File metadata and controls
46 lines (42 loc) · 1.29 KB
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
const request = require('supertest');
const app = require('./app');
const agent = request.agent(app);
describe('app', () => {
describe('when authenticated', () => {
beforeEach(async () => {
await agent
.post('/login')
.send('username=randombrandon&password=randompassword');
});
describe('POST /messages', () => {
describe('with non-empty content', () => {
describe('with url ', () => {
it('responds with success', async done => {
agent
.post('/messages')
.send("content=hello&personalWebsiteURL=https://odyssey.wildcodeschool.com")
.then((response) => {
expect(response.statusCode).toBe(201);
done();
});
});
});
});
});
describe('POST /messages', () => {
describe('with non-empty content', () => {
describe('with javascript injection ', () => {
it('responds with error', async done => {
agent
.post('/messages')
.send("content=hello&personalWebsiteURL=javascript:tutu")
.then((response) => {
expect(response.statusCode).toBe(400);
done();
});
});
});
});
});
});
})