mirror of
https://gitlab.com/RemixDev/deemix-gui.git
synced 2024-12-29 11:06:13 +00:00
test: added cookie parser test
This commit is contained in:
parent
78d70b7369
commit
e2c79f6ee6
30
server/src/tests/cookie-parser.spec.ts
Normal file
30
server/src/tests/cookie-parser.spec.ts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// Taken from https://github.com/visionmedia/supertest
|
||||||
|
|
||||||
|
import request from 'supertest'
|
||||||
|
import express from 'express'
|
||||||
|
import cookieParser from 'cookie-parser'
|
||||||
|
|
||||||
|
describe('request.agent(app)', function () {
|
||||||
|
const app = express()
|
||||||
|
app.use(cookieParser())
|
||||||
|
|
||||||
|
app.get('/', (_, res) => {
|
||||||
|
res.cookie('cookie', 'hey')
|
||||||
|
res.send()
|
||||||
|
})
|
||||||
|
|
||||||
|
app.get('/return', (req, res) => {
|
||||||
|
if (req.cookies.cookie) res.send(req.cookies.cookie)
|
||||||
|
else res.send(':(')
|
||||||
|
})
|
||||||
|
|
||||||
|
const agent = request.agent(app)
|
||||||
|
|
||||||
|
it('should save cookies', done => {
|
||||||
|
agent.get('/').expect('set-cookie', 'cookie=hey; Path=/', done)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should send cookies', done => {
|
||||||
|
agent.get('/return').expect('hey', done)
|
||||||
|
})
|
||||||
|
})
|
Loading…
Reference in a new issue