UNPKG

967 BJavaScriptView Raw
1/* global describe, it, before, after */
2const request = require('supertest');
3const test_routes = require('./test_routes');
4const service = require('../app');
5
6describe('service.basic', () => {
7
8 let app, agent;
9
10 before(async () => {
11 app = await service.run({
12 routes: {
13 '/': test_routes
14 }
15 });
16 agent = request.agent(app);
17 });
18
19 after((done) => {
20 app.close(() => {
21 done();
22 });
23 });
24
25
26 describe('GET', () => {
27 it('should GET routes', () => {
28 return agent.get('/test').expect(200);
29 });
30 });
31
32 describe('404', () => {
33 it('should 404 with no routes', () => {
34 return agent.get('/does_not_exist').expect(404);
35 });
36 });
37
38 describe('500', () => {
39 it('should 500 in a sane way', () => {
40 return agent.get('/500').expect(500);
41 });
42 });
43
44 describe('Custom error', () => {
45 it('return custom error codes', () => {
46 return agent.get('/555').expect(555);
47 });
48 });
49});