chore: moved tests folder outside src folder

This commit is contained in:
Roberto Tonino
2021-05-11 21:09:00 +02:00
parent cbd6bd4791
commit 8c92f78e52
5 changed files with 4 additions and 4 deletions

View 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('cookie parser', () => {
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)
})
})

9
server/tests/utils.ts Normal file
View File

@@ -0,0 +1,9 @@
import { Application } from 'express'
import request from 'supertest'
import { app } from '../src/app'
export const sendGet = (app: Application) => (uri: string) => request(app).get(uri).send()
export const sendPost = (app: Application) => (uri: string) => request(app).post(uri).send()
export const appSendGet = sendGet(app)
export const appSendPost = sendPost(app)