From ead9d706e6fde5ede5f2a19b778bf27c893020f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Fri, 31 Oct 2014 10:36:59 +0100 Subject: [PATCH] Add test for `remoting.rest.supportedTypes` --- test/rest.middleware.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/rest.middleware.test.js b/test/rest.middleware.test.js index 5b10302f..56b6d523 100644 --- a/test/rest.middleware.test.js +++ b/test/rest.middleware.test.js @@ -75,6 +75,22 @@ describe('loopback.rest', function() { }); }); + it('should honour `remoting.rest.supportedTypes`', function(done) { + var app = loopback(); + + // NOTE it is crucial to set `remoting` before creating any models + var supportedTypes = ['json', 'application/javascript', 'text/javascript']; + app.set('remoting', { rest: { supportedTypes: supportedTypes } }); + + app.model(MyModel); + app.use(loopback.rest()); + + request(app).get('/mymodels') + .set('Accept', 'text/html,application/xml;q=0.9,*/*;q=0.8') + .expect('Content-Type', 'application/json; charset=utf-8') + .expect(200, done); + }); + it('includes loopback.token when necessary', function(done) { givenUserModelWithAuth(); app.enableAuth();