Make tests importable
This commit is contained in:
parent
6981824d28
commit
d5d07d8806
|
@ -407,10 +407,12 @@ Schema.prototype.defineForeignKey = function defineForeignKey(className, key) {
|
||||||
/**
|
/**
|
||||||
* Close database connection
|
* Close database connection
|
||||||
*/
|
*/
|
||||||
Schema.prototype.disconnect = function disconnect() {
|
Schema.prototype.disconnect = function disconnect(cb) {
|
||||||
if (typeof this.adapter.disconnect === 'function') {
|
if (typeof this.adapter.disconnect === 'function') {
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
this.adapter.disconnect();
|
this.adapter.disconnect(cb);
|
||||||
|
} else if (cb) {
|
||||||
|
cb();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -439,6 +439,8 @@ function validationFailed(inst, v, cb) {
|
||||||
message = message[kind];
|
message = message[kind];
|
||||||
} else if (defaultMessages.common[kind]) {
|
} else if (defaultMessages.common[kind]) {
|
||||||
message = defaultMessages.common[kind];
|
message = defaultMessages.common[kind];
|
||||||
|
} else {
|
||||||
|
message = 'is invalid';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inst.errors.add(attr, message);
|
inst.errors.add(attr, message);
|
||||||
|
|
|
@ -2,28 +2,6 @@
|
||||||
var Schema = require('../index').Schema;
|
var Schema = require('../index').Schema;
|
||||||
var Text = Schema.Text;
|
var Text = Schema.Text;
|
||||||
|
|
||||||
// var schemas = {
|
|
||||||
// // riak: {},
|
|
||||||
// mysql: {
|
|
||||||
// database: 'myapp_test',
|
|
||||||
// username: 'root'
|
|
||||||
// },
|
|
||||||
// postgres: {
|
|
||||||
// database: 'myapp_test',
|
|
||||||
// username: 'postgres'
|
|
||||||
// },
|
|
||||||
// sqlite3: {
|
|
||||||
// database: ':memory:'
|
|
||||||
// },
|
|
||||||
// neo4j: { url: 'http://localhost:7474/' },
|
|
||||||
// // mongoose: { url: 'mongodb://travis:test@localhost:27017/myapp' },
|
|
||||||
// mongodb: { url: 'mongodb://travis:test@localhost:27017/myapp' },
|
|
||||||
// redis2: {},
|
|
||||||
// memory: {},
|
|
||||||
// cradle: {},
|
|
||||||
// nano: { url: 'http://localhost:5984/nano-test' }
|
|
||||||
// };
|
|
||||||
|
|
||||||
var nbSchemaRequests = 0;
|
var nbSchemaRequests = 0;
|
||||||
|
|
||||||
var batch;
|
var batch;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
var Schema = require('../').Schema;
|
var db = getSchema();
|
||||||
var db = new Schema('memory');
|
|
||||||
|
|
||||||
describe('defaults', function() {
|
describe('defaults', function() {
|
||||||
var Server;
|
var Server;
|
||||||
|
|
|
@ -9,7 +9,7 @@ var j = require('../'),
|
||||||
describe('hooks', function() {
|
describe('hooks', function() {
|
||||||
|
|
||||||
before(function() {
|
before(function() {
|
||||||
db = new Schema('memory');
|
db = getSchema();
|
||||||
|
|
||||||
User = db.define('User', {
|
User = db.define('User', {
|
||||||
email: String,
|
email: String,
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe('JSON property', function() {
|
||||||
var schema, Model;
|
var schema, Model;
|
||||||
|
|
||||||
it('should be defined', function() {
|
it('should be defined', function() {
|
||||||
schema = new Schema('memory');
|
schema = getSchema();
|
||||||
Model = schema.define('Model', {propertyName: Schema.JSON});
|
Model = schema.define('Model', {propertyName: Schema.JSON});
|
||||||
var m = new Model;
|
var m = new Model;
|
||||||
(new Boolean('propertyName' in m)).should.eql(true);
|
(new Boolean('propertyName' in m)).should.eql(true);
|
||||||
|
|
|
@ -15,7 +15,7 @@ function getValidAttributes() {
|
||||||
describe('validations', function() {
|
describe('validations', function() {
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
db = new j.Schema('memory');
|
db = getSchema();
|
||||||
User = db.define('User', {
|
User = db.define('User', {
|
||||||
email: String,
|
email: String,
|
||||||
name: String,
|
name: String,
|
||||||
|
@ -31,6 +31,10 @@ describe('validations', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
afterEach(function() {
|
||||||
|
db.disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
describe('presence', function() {
|
describe('presence', function() {
|
||||||
|
|
||||||
it('should validate presence', function() {
|
it('should validate presence', function() {
|
||||||
|
|
Loading…
Reference in New Issue