From 303b88b6fae88efb095152dcd165e68466832fb4 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Fri, 6 Nov 2015 21:28:19 -0600 Subject: [PATCH] Adjust api tests --- tasks/gulp-tests.js | 6 ++++-- test/helpers/api-integration.helper.js | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tasks/gulp-tests.js b/tasks/gulp-tests.js index 8264f91321..1fb2242e5f 100644 --- a/tasks/gulp-tests.js +++ b/tasks/gulp-tests.js @@ -297,6 +297,7 @@ gulp.task('test:e2e:safe', ['test:prepare', 'test:prepare:server'], (cb) => { }); gulp.task('test:api-v2', ['test:prepare:server'], (done) => { + process.env.API_VERSION = 'v2'; awaitPort(TEST_SERVER_PORT).then(() => { runMochaTests('./test/api/v2/**/*.js', server, done) }); @@ -329,15 +330,16 @@ gulp.task('test:api-v3', ['test:api-v3:unit', 'test:api-v3:integration']); gulp.task('test:api-v3:watch', ['test:api-v3:unit:watch', 'test:api-v3:integration:watch']); -gulp.task('test:api-v3:unit', ['test:prepare:server'], (done) => { +gulp.task('test:api-v3:unit', (done) => { runMochaTests('./test/api/v3/unit/**/*.js', null, done) }); -gulp.task('test:api-v3:unit:watch', ['test:prepare:server'], () => { +gulp.task('test:api-v3:unit:watch', () => { gulp.watch(['website/src/**', 'test/api/v3/unit/**'], ['test:api-v3:unit']); }); gulp.task('test:api-v3:integration', ['test:prepare:server'], (done) => { + process.env.API_VERSION = 'v3'; awaitPort(TEST_SERVER_PORT).then(() => { runMochaTests('./test/api/v3/unit/**/*.js', server, done) }); diff --git a/test/helpers/api-integration.helper.js b/test/helpers/api-integration.helper.js index b2b0ac99c6..1ddaa75b0d 100644 --- a/test/helpers/api-integration.helper.js +++ b/test/helpers/api-integration.helper.js @@ -208,9 +208,10 @@ export function resetHabiticaDB() { } function _requestMaker(user, method, additionalSets) { + const API_V = process.env.API_VERSION || 'v2' return (route, send, query) => { return new Promise((resolve, reject) => { - let request = superagent[method](`http://localhost:${API_TEST_SERVER_PORT}/api/v2${route}`) + let request = superagent[method](`http://localhost:${API_TEST_SERVER_PORT}/api/${API_V}${route}`) .accept('application/json'); if (user && user._id && user.apiToken) {