2014-03-21 19:18:00 +00:00
|
|
|
var loopback = require('../');
|
|
|
|
|
|
|
|
describe('hidden properties', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
var app = this.app = loopback();
|
|
|
|
var Product = this.Product = app.model('product', {
|
2014-03-21 19:53:04 +00:00
|
|
|
options: {hidden: ['secret']},
|
2014-03-21 19:18:00 +00:00
|
|
|
dataSource: loopback.memory()
|
|
|
|
});
|
2014-03-21 19:53:04 +00:00
|
|
|
app.use(loopback.rest());
|
|
|
|
|
|
|
|
Product.create(
|
|
|
|
{name: 'pencil', secret: 'secret'},
|
|
|
|
done
|
|
|
|
);
|
2014-03-21 19:18:00 +00:00
|
|
|
});
|
|
|
|
|
2014-03-21 19:53:04 +00:00
|
|
|
it('should hide a property remotely', function (done) {
|
|
|
|
request(this.app)
|
|
|
|
.get('/products')
|
|
|
|
.expect('Content-Type', /json/)
|
|
|
|
.expect(200)
|
|
|
|
.end(function(err, res){
|
|
|
|
if(err) return done(err);
|
|
|
|
var product = res.body[0];
|
|
|
|
assert.equal(product.secret, undefined);
|
|
|
|
done();
|
|
|
|
});
|
2014-03-21 19:18:00 +00:00
|
|
|
});
|
|
|
|
});
|