From 72405df6a8df0dc1d2c776f8786a82c175dcd16d Mon Sep 17 00:00:00 2001 From: Eran Hammer Date: Sat, 28 Dec 2013 16:44:13 -0800 Subject: [PATCH] Fix view layout schema definition. Closes #1335 --- lib/schema.js | 4 ++-- test/integration/response.js | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/schema.js b/lib/schema.js index f733e1e12..d6302645b 100755 --- a/lib/schema.js +++ b/lib/schema.js @@ -101,7 +101,7 @@ internals.serverSchema = { basePath: Joi.string(), compileOptions: Joi.object(), runtimeOptions: Joi.object(), - layout: Joi.boolean(), + layout: Joi.string().allow(false, true), layoutKeyword: Joi.string(), encoding: Joi.string(), isCached: Joi.boolean(), @@ -266,7 +266,7 @@ internals.viewSchema = { basePath: Joi.string().allow(''), compileOptions: Joi.object(), runtimeOptions: Joi.object(), - layout: Joi.boolean(), + layout: Joi.string().allow(false, true), layoutKeyword: Joi.string(), encoding: Joi.string(), isCached: Joi.boolean(), diff --git a/test/integration/response.js b/test/integration/response.js index c30411fc9..b8d678012 100755 --- a/test/integration/response.js +++ b/test/integration/response.js @@ -1799,6 +1799,31 @@ describe('Response', function () { }); }); + it('returns response with custom server layout', function (done) { + + var layoutServer = new Hapi.Server({ debug: false }); + layoutServer.views({ + engines: { 'html': 'handlebars' }, + path: __dirname + '/../unit/templates', + layout: 'otherLayout' + }); + + var handler = function (request, reply) { + + return reply.view('valid/test', { title: 'test', message: 'Hapi' }); + }; + + layoutServer.route({ method: 'GET', path: '/', handler: handler }); + + layoutServer.inject('/', function (res) { + + expect(res.result).to.exist; + expect(res.statusCode).to.equal(200); + expect(res.result).to.equal('test:
\n

Hapi

\n
\n'); + done(); + }); + }); + it('returns response without layout', function (done) { var layoutServer = new Hapi.Server({ debug: false });