Skip to content

Commit

Permalink
Fix tests: mocking authenticate and catch error
Browse files Browse the repository at this point in the history
Signed-off-by: José Luis Di Biase <[email protected]>
  • Loading branch information
josx committed Aug 22, 2017
1 parent 3434311 commit fe04ceb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/restClient.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -34,6 +35,7 @@ function setupClient(options = {}) {

fakeClient = {
service: (resource) => fakeService,
authenticate: () => Promise.resolve(authenticateResult)
};

aorClient = restClient(fakeClient, options);
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit fe04ceb

Please sign in to comment.