mirror of
https://gitlab.com/RemixDev/deemix-gui.git
synced 2024-12-29 11:06:13 +00:00
feat: added root path first test
This commit is contained in:
parent
eb91ff06d6
commit
78d70b7369
|
@ -10,7 +10,7 @@
|
|||
"prebuild": "yarn lint",
|
||||
"build": "tsc",
|
||||
"test": "jest",
|
||||
"test-watch": "jest --watch"
|
||||
"test-watch": "jest --watchAll"
|
||||
},
|
||||
"dependencies": {
|
||||
"cookie-parser": "1.4.5",
|
||||
|
|
|
@ -14,7 +14,7 @@ import { registerApis } from './routes/api/register'
|
|||
const PORT = normalizePort(process.env.PORT || '6595')
|
||||
|
||||
const debug = initDebug('deemix-gui:server')
|
||||
const app: Application = express()
|
||||
export const app: Application = express()
|
||||
const server = http.createServer(app)
|
||||
|
||||
/* === Middlewares === */
|
||||
|
@ -31,7 +31,9 @@ registerApis(app)
|
|||
app.set('port', PORT)
|
||||
|
||||
/* === Server port === */
|
||||
server.listen(PORT)
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
server.listen(PORT)
|
||||
}
|
||||
|
||||
/* === Server callbacks === */
|
||||
server.on('error', getErrorCb(PORT))
|
||||
|
|
28
server/src/routes/index.spec.ts
Normal file
28
server/src/routes/index.spec.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
import request from 'supertest'
|
||||
import { app } from '../app'
|
||||
|
||||
describe('root path requests', () => {
|
||||
it('it responds 200 to the GET method', async () => {
|
||||
const result = await request(app).get('/').send()
|
||||
|
||||
expect(result.status).toBe(200)
|
||||
})
|
||||
|
||||
it('it responds 404 to the POST method', async () => {
|
||||
const result = await request(app).post('/').send()
|
||||
|
||||
expect(result.status).toBe(404)
|
||||
})
|
||||
|
||||
it('it responds 404 to the PATCH method', async () => {
|
||||
const result = await request(app).patch('/').send()
|
||||
|
||||
expect(result.status).toBe(404)
|
||||
})
|
||||
|
||||
it('it responds 404 to the DELETE method', async () => {
|
||||
const result = await request(app).delete('/').send()
|
||||
|
||||
expect(result.status).toBe(404)
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue