diff --git a/test/fixtures/coffee-app-2/app.coffee b/test/fixtures/coffee-app-2/app.coffee new file mode 100644 index 0000000..534b35f --- /dev/null +++ b/test/fixtures/coffee-app-2/app.coffee @@ -0,0 +1,5 @@ +loopback = require 'loopback' +boot = require '../../../' + +module.exports = client = loopback() +boot(client, __dirname) diff --git a/test/fixtures/coffee-app-2/boot/configure.coffee b/test/fixtures/coffee-app-2/boot/configure.coffee new file mode 100644 index 0000000..5afa454 --- /dev/null +++ b/test/fixtures/coffee-app-2/boot/configure.coffee @@ -0,0 +1,2 @@ +module.exports = (app) -> + app.set 'custom-key', 'custom-value' diff --git a/test/fixtures/coffee-app-2/component-config.yaml b/test/fixtures/coffee-app-2/component-config.yaml new file mode 100644 index 0000000..2613c21 --- /dev/null +++ b/test/fixtures/coffee-app-2/component-config.yaml @@ -0,0 +1,2 @@ +debug: + option: "value" diff --git a/test/fixtures/coffee-app-2/datasources.yaml b/test/fixtures/coffee-app-2/datasources.yaml new file mode 100644 index 0000000..33c052e --- /dev/null +++ b/test/fixtures/coffee-app-2/datasources.yaml @@ -0,0 +1,2 @@ +db: + connector: "remote" diff --git a/test/fixtures/coffee-app-2/model-config.yaml b/test/fixtures/coffee-app-2/model-config.yaml new file mode 100644 index 0000000..2be5744 --- /dev/null +++ b/test/fixtures/coffee-app-2/model-config.yaml @@ -0,0 +1,4 @@ +Customer: + dataSource: "db" +Order: + dataSource: "db" diff --git a/test/fixtures/coffee-app-2/models/customer.coffee b/test/fixtures/coffee-app-2/models/customer.coffee new file mode 100644 index 0000000..2164665 --- /dev/null +++ b/test/fixtures/coffee-app-2/models/customer.coffee @@ -0,0 +1,3 @@ +module.exports = (Customer) -> + Customer.settings._customized = 'Customer' + Customer.base.settings._customized = 'Base' diff --git a/test/fixtures/coffee-app-2/models/customer.json b/test/fixtures/coffee-app-2/models/customer.json new file mode 100644 index 0000000..c1df7a5 --- /dev/null +++ b/test/fixtures/coffee-app-2/models/customer.json @@ -0,0 +1,4 @@ +{ + "name": "Customer", + "base": "User" +} diff --git a/test/fixtures/coffee-app-2/models/order.coffee b/test/fixtures/coffee-app-2/models/order.coffee new file mode 100644 index 0000000..f374fa9 --- /dev/null +++ b/test/fixtures/coffee-app-2/models/order.coffee @@ -0,0 +1,3 @@ +module.exports = (Model) -> + Model.settings._customized = 'Order' + Model.base.settings._customized = 'Base' diff --git a/test/fixtures/coffee-app-2/models/order.yaml b/test/fixtures/coffee-app-2/models/order.yaml new file mode 100644 index 0000000..aa9999c --- /dev/null +++ b/test/fixtures/coffee-app-2/models/order.yaml @@ -0,0 +1 @@ +name: "Order" diff --git a/test/model-load-config.test.js b/test/model-load-config.test.js index b8fbe97..f910df5 100644 --- a/test/model-load-config.test.js +++ b/test/model-load-config.test.js @@ -7,7 +7,7 @@ var boot = require('../'); var fs = require('fs-extra'); var path = require('path'); var expect = require('chai').expect; -var loadConfig = require('load-config-file'); +var loadConfig = require('../lib/load-config'); var yaml = require('js-yaml'); loadConfig.register(['.yaml', '.yml'], yaml.safeLoad); @@ -15,7 +15,7 @@ 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'); +var COFFEE_APP = path.join(__dirname, 'fixtures', 'coffee-app-2'); describe('compiler', function() { function getModelByName(aModels, aName) { @@ -35,6 +35,20 @@ describe('compiler', function() { done(); }); }); + it('loads component-config.yaml file', function(done) { + boot.compile(COFFEE_APP, function(err, context) { + if (err) return done(err); + var instructions = context.instructions; + var component = instructions.components[0]; + expect(component).to.eql({ + sourceFile: require.resolve('debug'), + config: { + option: 'value', + }, + }); + done(); + }); + }); }); });