Skip to content

Commit

Permalink
Expose path to the built-in favicon file
Browse files Browse the repository at this point in the history
The path is available via `loopback.faviconFile`.
  • Loading branch information
Miroslav Bajtoš committed Nov 3, 2014
1 parent 2d0b74b commit edd464a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
19 changes: 19 additions & 0 deletions lib/loopback.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,25 @@ if (loopback.isServer) {
});
}

/*
* Expose path to the default favicon file
*
* ***only in node***
*/

if (loopback.isServer) {
/**
* Path to a default favicon shipped with LoopBack.
*
* **Example**
*
* ```js
* app.use(require('serve-favicon')(loopback.faviconFile));
* ```
*/
loopback.faviconFile = path.resolve(__dirname, '../favicon.ico');
}

/*!
* Error handler title
*/
Expand Down
15 changes: 12 additions & 3 deletions test/loopback.test.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var it = require('./util/it');

describe('loopback', function() {
var nameCounter = 0;
var uniqueModelName;
Expand All @@ -11,6 +13,13 @@ describe('loopback', function() {
expect(loopback.ValidationError).to.be.a('function')
.and.have.property('name', 'ValidationError');
});

it.onServer('includes `faviconFile`', function() {
var file = loopback.faviconFile;
expect(file, 'faviconFile').to.not.equal(undefined);
expect(require('fs').existsSync(loopback.faviconFile), 'file exists')
.to.equal(true);
});
});

describe('loopback.createDataSource(options)', function() {
Expand Down Expand Up @@ -68,19 +77,19 @@ describe('loopback', function() {
describe('loopback.remoteMethod(Model, fn, [options]);', function() {
it("Setup a remote method.", function() {
var Product = loopback.createModel('product', {price: Number});

Product.stats = function(fn) {
// ...
}

loopback.remoteMethod(
Product.stats,
{
returns: {arg: 'stats', type: 'array'},
http: {path: '/info', verb: 'get'}
}
);

assert.equal(Product.stats.returns.arg, 'stats');
assert.equal(Product.stats.returns.type, 'array');
assert.equal(Product.stats.http.path, '/info');
Expand Down

0 comments on commit edd464a

Please sign in to comment.