Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Commit

Permalink
Ensure services use internal methods (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
t2t2 authored and daffl committed Jun 4, 2016
1 parent cf3345e commit f49db8b
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions src/common-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,4 +480,58 @@ export default function common(people, _ids, errors, idProp = 'id') {
}).catch(done);
});
});

describe('Services don\'t call public methods internally', () => {
// If any of the public methods are called the test fails
let throwing = people.extend({
find() {
throw new Error('find method called');
},
get() {
throw new Error('get method called');
},
create() {
throw new Error('create method called');
},
update() {
throw new Error('update method called');
},
patch() {
throw new Error('patch method called');
},
remove() {
throw new Error('remove method called');
}
});

it('find', () => {
return people.find.call(throwing);
});

it('get', () => {
return people.get.call(throwing, _ids.Doug);
});

it('create', () => {
return people.create.call(throwing, {
name: 'Bob',
age: 25
}).then(bob => {
// .remove isn't tested here
return people.remove(bob[idProp].toString());
});
});

it('update', () => {
return people.update.call(throwing, _ids.Doug, { name: 'Dougler' });
});

it('patch', () => {
return people.patch.call(throwing, _ids.Doug, { name: 'PatchDoug' });
});

it('remove', () => {
return people.remove.call(throwing, _ids.Doug);
});
});
}

0 comments on commit f49db8b

Please sign in to comment.