test: separate assertions from test flow control
This commit is contained in:
parent
9ad29ddbaa
commit
5a7cac6852
|
@ -211,8 +211,14 @@ describe('Discover model foreign keys', function () {
|
|||
});
|
||||
|
||||
describe('Discover LDL schema from a table', function () {
|
||||
it('should return an LDL schema for INVENTORY', function (done) {
|
||||
db.discoverSchema('INVENTORY', {owner: 'STRONGLOOP'}, function (err, schema) {
|
||||
var schema;
|
||||
before(function (done) {
|
||||
db.discoverSchema('INVENTORY', {owner: 'STRONGLOOP'}, function (err, schema_) {
|
||||
schema = schema_;
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
it('should return an LDL schema for INVENTORY', function () {
|
||||
var productId = 'productId' in schema.properties ? 'productId' : 'productid';
|
||||
var locationId = 'locationId' in schema.properties ? 'locationId' : 'locationid';
|
||||
console.error('schema:', schema);
|
||||
|
@ -232,14 +238,18 @@ describe('Discover LDL schema from a table', function () {
|
|||
assert.strictEqual(schema.properties.available.type, 'Number');
|
||||
assert(schema.properties.total);
|
||||
assert.strictEqual(schema.properties.total.type, 'Number');
|
||||
done(null, schema);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Discover and build models', function () {
|
||||
it('should discover and build models', function (done) {
|
||||
db.discoverAndBuildModels('INVENTORY', {owner: 'STRONGLOOP', visited: {}, associations: true}, function (err, models) {
|
||||
var models;
|
||||
before(function (done) {
|
||||
db.discoverAndBuildModels('INVENTORY', {owner: 'STRONGLOOP', visited: {}, associations: true}, function (err, models_) {
|
||||
models = models_;
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
it('should discover and build models', function () {
|
||||
assert(models.Inventory, 'Inventory model should be discovered and built');
|
||||
var schema = models.Inventory.definition;
|
||||
var productId = 'productId' in schema.properties ? 'productId' : 'productid';
|
||||
|
@ -256,10 +266,12 @@ describe('Discover and build models', function () {
|
|||
assert.strictEqual(schema.properties.available.type, Number);
|
||||
assert(schema.properties.total);
|
||||
assert.strictEqual(schema.properties.total.type, Number);
|
||||
});
|
||||
it('should be able to find an instance', function (done) {
|
||||
assert(models.Inventory, 'Inventory model must exist');
|
||||
models.Inventory.findOne(function (err, inv) {
|
||||
assert(!err, 'error should not be reported');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue