From a1d4d794313753dcf16713312573b5154da20286 Mon Sep 17 00:00:00 2001 From: Harish Krishna Date: Fri, 5 Dec 2014 16:20:13 -0500 Subject: [PATCH] functional failure test fixed --- test/unit/controller/suggest.js | 52 ++++++++++++++++----------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/test/unit/controller/suggest.js b/test/unit/controller/suggest.js index 453e22c8..8aade740 100644 --- a/test/unit/controller/suggest.js +++ b/test/unit/controller/suggest.js @@ -93,32 +93,32 @@ module.exports.tests.functional_success = function(test, common) { }; // functionally test controller (backend failure) -// module.exports.tests.functional_failure = function(test, common) { -// test('functional failure', function(t) { -// var backend = mockBackend( 'client/suggest/fail/1', function( cmd ){ -// if( cmd.body.docs ){ -// t.deepEqual(cmd, { -// body: { docs: [ -// { _id: 'mockid1', _index: 'pelias', _type: 'mocktype' }, -// { _id: 'mockid2', _index: 'pelias', _type: 'mocktype' }] -// } -// }, 'correct mget command'); -// } else if (cmd.body.layers) { -// // layers are set exclusively for admin: test for admin-only layers -// t.deepEqual(cmd, { body: { a: 'b', layers: [ 'admin0', 'admin1', 'admin2' ] }, index: 'pelias' }, - // 'correct suggest/admin command'); -// } else { -// t.deepEqual(cmd, { body: { a: 'b' }, index: 'pelias' }, 'correct suggest command'); -// } -// }); -// var controller = setup( backend, mockQuery() ); -// var next = function( message ){ -// t.equal(message,'a backend error occurred','error passed to errorHandler'); -// t.end(); -// }; -// controller( { clean: { a: 'b' } }, undefined, next ); -// }); -// }; +module.exports.tests.functional_failure = function(test, common) { + test('functional failure', function(t) { + var backend = mockBackend( 'client/suggest/fail/1', function( cmd ){ + if( cmd.body.docs ){ + t.deepEqual(cmd, { + body: { docs: [ + { _id: 'mockid1', _index: 'pelias', _type: 'mocktype' }, + { _id: 'mockid2', _index: 'pelias', _type: 'mocktype' }] + } + }, 'correct mget command'); + } else if (cmd.body.layers) { + // layers are set exclusively for admin: test for admin-only layers + t.deepEqual(cmd, { body: { a: 'b', layers: [ 'admin0', 'admin1', 'admin2' ] }, index: 'pelias' }, + 'correct suggest/admin command'); + } else { + t.deepEqual(cmd, { body: { a: 'b' }, index: 'pelias' }, 'correct suggest command'); + } + }); + var controller = setup( backend, mockQuery() ); + var next = function( message ){ + t.equal(message,'a backend error occurred','error passed to errorHandler'); + }; + controller( { clean: { a: 'b' } }, undefined, next ); + t.end(); + }); +}; module.exports.all = function (tape, common) {