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')