From 79f530fc43a5f393db44928c163f4247339dce56 Mon Sep 17 00:00:00 2001 From: meltedfork Date: Sat, 5 May 2018 21:08:00 -0500 Subject: [PATCH] additional main api tests for name and root --- test/api/main.test.js | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/test/api/main.test.js b/test/api/main.test.js index e3215fc..aab2331 100644 --- a/test/api/main.test.js +++ b/test/api/main.test.js @@ -1,17 +1,47 @@ -import { expect } from 'chai' import supertest from 'supertest' import server from '../../src/index' describe('Main API routes', () => { let api + let path beforeEach(() => { api = supertest(server) }) - describe('GET /version', () => { - let path + describe('GET /', () => { + // this beforeEach is needed as SuperAgent doesn't like .end() called more than once + beforeEach(() => { + path = api.get('/') + }) + xit('responds with available routes', () => { + // TODO: figure out how to deal with SuperAgent + }) + + it('responds with json', () => { + return path.expect('Content-Type', /json/) + }) + }) + + describe('GET /name', () => { + // this beforeEach is needed as SuperAgent doesn't like .end() called more than once + beforeEach(() => { + path = api.get('/name') + }) + + it('responds with package name', () => { + return path.expect(200, { + name: process.env.npm_package_name + }) + }) + + it('responds with json', () => { + return path.expect('Content-Type', /json/) + }) + }) + + describe('GET /version', () => { // this beforeEach is needed as SuperAgent doesn't like .end() called more than once beforeEach(() => { path = api.get('/version')