|
| 1 | +import * as assert from 'assert'; |
| 2 | +import { GetV1PingExpress } from '../../../src/typedRoutes/api/v1/pingExpress'; |
| 3 | +import { GetV2PingExpress } from '../../../src/typedRoutes/api/v2/pingExpress'; |
| 4 | +import { assertDecode } from './common'; |
| 5 | +import 'should'; |
| 6 | +import 'should-http'; |
| 7 | +import { setupAgent } from '../../lib/testutil'; |
| 8 | + |
| 9 | +describe('PingExpress route tests', function () { |
| 10 | + describe('PostV1PingExpress route definition', function () { |
| 11 | + it('should have the correct path', function () { |
| 12 | + assert.strictEqual(GetV1PingExpress.path, '/api/v1/pingexpress'); |
| 13 | + }); |
| 14 | + |
| 15 | + it('should have the correct HTTP method', function () { |
| 16 | + assert.strictEqual(GetV1PingExpress.method, 'GET'); |
| 17 | + }); |
| 18 | + |
| 19 | + it('should have the correct response types', function () { |
| 20 | + assert.ok(GetV1PingExpress.response[200]); |
| 21 | + assert.ok(GetV1PingExpress.response[404]); |
| 22 | + }); |
| 23 | + }); |
| 24 | + |
| 25 | + describe('PostV2PingExpress route definition', function () { |
| 26 | + it('should have the correct path', function () { |
| 27 | + assert.strictEqual(GetV2PingExpress.path, '/api/v2/pingexpress'); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should have the correct HTTP method', function () { |
| 31 | + assert.strictEqual(GetV2PingExpress.method, 'GET'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should have the correct response types', function () { |
| 35 | + assert.ok(GetV2PingExpress.response[200]); |
| 36 | + assert.ok(GetV2PingExpress.response[404]); |
| 37 | + }); |
| 38 | + }); |
| 39 | + |
| 40 | + describe('Supertest Integration Tests', function () { |
| 41 | + const agent = setupAgent(); |
| 42 | + |
| 43 | + const expectedStatus = 'express server is ok!'; |
| 44 | + |
| 45 | + it('should resolve GET /api/v1/pingexpress with the expected payload', async function () { |
| 46 | + const result = await agent.get('/api/v1/pingexpress'); |
| 47 | + |
| 48 | + assert.strictEqual(result.status, 200); |
| 49 | + result.body.should.have.property('status'); |
| 50 | + assert.strictEqual(result.body.status, expectedStatus); |
| 51 | + |
| 52 | + const decodedResponse = assertDecode(GetV1PingExpress.response[200], result.body); |
| 53 | + assert.strictEqual(decodedResponse.status, expectedStatus); |
| 54 | + }); |
| 55 | + |
| 56 | + it('should resolve GET /api/v2/pingexpress with the expected payload', async function () { |
| 57 | + const result = await agent.get('/api/v2/pingexpress'); |
| 58 | + |
| 59 | + assert.strictEqual(result.status, 200); |
| 60 | + result.body.should.have.property('status'); |
| 61 | + assert.strictEqual(result.body.status, expectedStatus); |
| 62 | + |
| 63 | + const decodedResponse = assertDecode(GetV2PingExpress.response[200], result.body); |
| 64 | + assert.strictEqual(decodedResponse.status, expectedStatus); |
| 65 | + }); |
| 66 | + }); |
| 67 | +}); |
0 commit comments