From fe04cebd4069277c04b4fde8d3ef286a6de36855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Di=20Biase?= Date: Tue, 22 Aug 2017 09:37:28 -0300 Subject: [PATCH] Fix tests: mocking authenticate and catch error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Luis Di Biase --- test/restClient.spec.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/restClient.spec.js b/test/restClient.spec.js index 6cfb75c..ca37ef5 100644 --- a/test/restClient.spec.js +++ b/test/restClient.spec.js @@ -18,6 +18,7 @@ const getResult = { id: 1, title: 'gotten' }; const updateResult = { id: 1, title: 'updated' }; const createResult = { id: 1, title: 'created' }; const removeResult = { id: 1, title: 'deleted' }; +const authenticateResult = {}; let aorClient, fakeClient, fakeService; @@ -34,6 +35,7 @@ function setupClient(options = {}) { fakeClient = { service: (resource) => fakeService, + authenticate: () => Promise.resolve(authenticateResult) }; aorClient = restClient(fakeClient, options); @@ -341,7 +343,8 @@ describe('Rest Client', function () { return aorClient('WRONG_TYPE', 'posts', {}) .then(result => { throw new Error("client must reject"); - }); + }) + .catch(err => {}); } catch (err) { expect(err).to.deep.equal(errorRes); }