mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
first attempt to fix fialing api-v3 tests
This commit is contained in:
@@ -1,5 +0,0 @@
|
|||||||
We need to clean up this directory. The *real* tests are in spec/ mock/ e2e/ and api.mocha.coffee. We want to:
|
|
||||||
|
|
||||||
1. Move all old / deprecated tests from casper, test2, etc into spec, mock, e2e
|
|
||||||
1. Remove dependency of api.mocha.coffee on Derby, port it to Mongoose
|
|
||||||
1. Add better test-coverage
|
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
# So you want to write API integration tests?
|
# So you want to write API integration tests?
|
||||||
|
|
||||||
|
@TODO rewrite
|
||||||
|
|
||||||
That's great! This README will serve as a quick primer for style conventions and practices for these tests.
|
That's great! This README will serve as a quick primer for style conventions and practices for these tests.
|
||||||
|
|
||||||
## What is this?
|
## What is this?
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
/* eslint-disable no-use-before-define */
|
/* eslint-disable no-use-before-define */
|
||||||
|
import nconf from 'nconf';
|
||||||
import { MongoClient as mongo } from 'mongodb';
|
import { MongoClient as mongo } from 'mongodb';
|
||||||
|
|
||||||
const DB_URI = 'mongodb://localhost/habitrpg_test';
|
|
||||||
|
|
||||||
// Useful for checking things that have been deleted,
|
// Useful for checking things that have been deleted,
|
||||||
// but you no longer have access to,
|
// but you no longer have access to,
|
||||||
// like private parties or users
|
// like private parties or users
|
||||||
@@ -81,7 +79,7 @@ export async function getDocument (collectionName, doc) {
|
|||||||
|
|
||||||
export function connectToMongo () {
|
export function connectToMongo () {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
mongo.connect(DB_URI, (err, db) => {
|
mongo.connect(nconf.get('NODE_DB_URI'), (err, db) => {
|
||||||
if (err) return reject(err);
|
if (err) return reject(err);
|
||||||
|
|
||||||
resolve(db);
|
resolve(db);
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
/* eslint-disable no-use-before-define */
|
/* eslint-disable no-use-before-define */
|
||||||
|
|
||||||
import superagent from 'superagent';
|
import superagent from 'superagent';
|
||||||
|
import nconf from 'nconf';
|
||||||
|
import app from '../../../website/src/server';
|
||||||
|
|
||||||
const API_TEST_SERVER_PORT = 3003;
|
const API_TEST_SERVER_PORT = nconf.get('PORT');
|
||||||
let apiVersion;
|
let apiVersion;
|
||||||
|
|
||||||
// Sets up an abject that can make all REST requests
|
// Sets up an abject that can make all REST requests
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ import { defaultsDeep as defaults } from 'lodash';
|
|||||||
import { model as User } from '../../website/src/models/user';
|
import { model as User } from '../../website/src/models/user';
|
||||||
import { model as Group } from '../../website/src/models/group';
|
import { model as Group } from '../../website/src/models/group';
|
||||||
|
|
||||||
mongoose.Promise = require('q').Promise;
|
|
||||||
|
|
||||||
mongoose.connect('mongodb://localhost/habitica-unit-tests');
|
|
||||||
let connection = mongoose.connection;
|
let connection = mongoose.connection;
|
||||||
|
|
||||||
before((done) => {
|
before((done) => {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
import Q from 'q';
|
import Q from 'q';
|
||||||
mongoose.Promise = Q.Promise;
|
|
||||||
|
|
||||||
import { wrap as wrapUser } from '../../common/script/index';
|
import { wrap as wrapUser } from '../../common/script/index';
|
||||||
import { model as User } from '../../website/src/models/user';
|
import { model as User } from '../../website/src/models/user';
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/* eslint-disable no-undef */
|
/* eslint-disable no-undef */
|
||||||
require('babel-core/register');
|
|
||||||
//------------------------------
|
//------------------------------
|
||||||
// Global modules
|
// Global modules
|
||||||
//------------------------------
|
//------------------------------
|
||||||
|
|||||||
@@ -5,5 +5,4 @@
|
|||||||
--growl
|
--growl
|
||||||
--globals io
|
--globals io
|
||||||
--compilers js:babel-core/register
|
--compilers js:babel-core/register
|
||||||
--require test/api-legacy/api-helper
|
|
||||||
--require ./test/helpers/globals.helper
|
--require ./test/helpers/globals.helper
|
||||||
|
|||||||
Reference in New Issue
Block a user