+ test load custom model config format
This commit is contained in:
parent
6c4b025ebf
commit
ff085bdd6a
|
@ -46,6 +46,7 @@
|
||||||
"eslint": "^2.11.1",
|
"eslint": "^2.11.1",
|
||||||
"eslint-config-loopback": "^1.0.0",
|
"eslint-config-loopback": "^1.0.0",
|
||||||
"fs-extra": "^0.30.0",
|
"fs-extra": "^0.30.0",
|
||||||
|
"js-yaml": "^3.8.1",
|
||||||
"loopback": "^3.0.0",
|
"loopback": "^3.0.0",
|
||||||
"mocha": "^2.5.3",
|
"mocha": "^2.5.3",
|
||||||
"supertest": "^1.2.0"
|
"supertest": "^1.2.0"
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
{
|
{
|
||||||
"Customer": {
|
"Customer": {
|
||||||
"dataSource": "db"
|
"dataSource": "db"
|
||||||
|
},
|
||||||
|
"Order": {
|
||||||
|
"dataSource": "db"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = (Model) ->
|
||||||
|
Model.settings._customized = 'Order'
|
||||||
|
Model.base.settings._customized = 'Base'
|
|
@ -0,0 +1 @@
|
||||||
|
name: "Order"
|
|
@ -0,0 +1,40 @@
|
||||||
|
// Copyright IBM Corp. 2014,2016. All Rights Reserved.
|
||||||
|
// Node module: loopback-boot
|
||||||
|
// This file is licensed under the MIT License.
|
||||||
|
// License text available at https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
var boot = require('../');
|
||||||
|
var fs = require('fs-extra');
|
||||||
|
var path = require('path');
|
||||||
|
var expect = require('chai').expect;
|
||||||
|
var loadConfig = require('load-config-file');
|
||||||
|
var yaml = require('js-yaml');
|
||||||
|
|
||||||
|
loadConfig.register(['.yaml', '.yml'], yaml.safeLoad);
|
||||||
|
|
||||||
|
// add coffee-script to require.extensions
|
||||||
|
require('coffee-script/register');
|
||||||
|
|
||||||
|
var COFFEE_APP = path.join(__dirname, 'fixtures', 'coffee-app');
|
||||||
|
|
||||||
|
describe('compiler', function() {
|
||||||
|
function getModelByName(aModels, aName) {
|
||||||
|
for (let model of aModels) {
|
||||||
|
if (model.name === aName) return model;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
describe.only('from directory', function() {
|
||||||
|
it('loads Model yaml config files', function(done) {
|
||||||
|
boot.compile(COFFEE_APP, function(err, context) {
|
||||||
|
if (err) return done(err);
|
||||||
|
var instructions = context.instructions;
|
||||||
|
|
||||||
|
var model = getModelByName(instructions.models, 'Order');
|
||||||
|
expect(model).to.be.exist;
|
||||||
|
expect(model.sourceFile).to.be.exist;
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue