Merge pull request #2888 from strongloop/make-test-individually-runable

make test individually runable
This commit is contained in:
David Cheung 2016-11-17 18:29:00 -05:00 committed by GitHub
commit 61c0c85ab5
5 changed files with 19 additions and 9 deletions

View File

@ -16,7 +16,11 @@ Token.attachTo(ds);
var ACL = loopback.ACL; var ACL = loopback.ACL;
describe('loopback.token(options)', function() { describe('loopback.token(options)', function() {
beforeEach(createTestingToken); var app;
beforeEach(function(done) {
app = loopback();
createTestingToken.call(this, done);
});
it('should populate req.token from the query string', function(done) { it('should populate req.token from the query string', function(done) {
createTestAppAndRequest(this.token, done) createTestAppAndRequest(this.token, done)
@ -428,7 +432,9 @@ describe('AccessToken', function() {
}); });
describe('app.enableAuth()', function() { describe('app.enableAuth()', function() {
var app;
beforeEach(function setupAuthWithModels() { beforeEach(function setupAuthWithModels() {
app = loopback();
app.enableAuth({ dataSource: ds }); app.enableAuth({ dataSource: ds });
}); });
beforeEach(createTestingToken); beforeEach(createTestingToken);

View File

@ -16,11 +16,15 @@ var expect = require('chai').expect;
var it = require('./util/it'); var it = require('./util/it');
describe('app', function() { describe('app', function() {
var app;
beforeEach(function() {
app = loopback();
});
describe.onServer('.middleware(phase, handler)', function() { describe.onServer('.middleware(phase, handler)', function() {
var app, steps; var steps;
beforeEach(function setup() { beforeEach(function setup() {
app = loopback();
steps = []; steps = [];
}); });

1
test/mocha.opts Normal file
View File

@ -0,0 +1 @@
--require ./test/support.js

View File

@ -4,12 +4,16 @@
// License text available at https://opensource.org/licenses/MIT // License text available at https://opensource.org/licenses/MIT
var async = require('async'); var async = require('async');
var chai = require('chai');
var describe = require('./util/describe');
var loopback = require('../'); var loopback = require('../');
var ACL = loopback.ACL; var ACL = loopback.ACL;
var defineModelTestsWithDataSource = require('./util/model-tests'); var defineModelTestsWithDataSource = require('./util/model-tests');
var PersistedModel = loopback.PersistedModel; var PersistedModel = loopback.PersistedModel;
var sinonChai = require('sinon-chai');
var describe = require('./util/describe'); var expect = chai.expect;
chai.use(sinonChai);
describe('Model / PersistedModel', function() { describe('Model / PersistedModel', function() {
defineModelTestsWithDataSource({ defineModelTestsWithDataSource({

View File

@ -12,7 +12,6 @@ expect = require('chai').expect;
loopback = require('../'); loopback = require('../');
memoryConnector = loopback.Memory; memoryConnector = loopback.Memory;
GeoPoint = loopback.GeoPoint; GeoPoint = loopback.GeoPoint;
app = null;
TaskEmitter = require('strong-task-emitter'); TaskEmitter = require('strong-task-emitter');
request = require('supertest'); request = require('supertest');
var RemoteObjects = require('strong-remoting'); var RemoteObjects = require('strong-remoting');
@ -21,10 +20,6 @@ var RemoteObjects = require('strong-remoting');
// for tests using the built-in User model // for tests using the built-in User model
loopback.User.settings.saltWorkFactor = 4; loopback.User.settings.saltWorkFactor = 4;
beforeEach(function() {
this.app = app = loopback();
});
assertValidDataSource = function(dataSource) { assertValidDataSource = function(dataSource) {
// has methods // has methods
assert.isFunc(dataSource, 'createModel'); assert.isFunc(dataSource, 'createModel');