added test for non-existing links

This commit is contained in:
Theodor Diaconu 2016-11-21 16:05:52 +02:00
parent d1bdae5360
commit afe67aa254

View file

@ -304,7 +304,7 @@ describe('Collection Links', function () {
assert.isUndefined(CommentCollection.findOne(comment._id));
});
it ('Should allow actions from inversed links', function () {
it('Should allow actions from inversed links', function () {
let comment = {text: 'abc'};
let postId = PostCollection.insert({text: 'hello'});
@ -333,5 +333,16 @@ describe('Collection Links', function () {
let postMetaCategoryLink = PostCollection.getLink(insertedPostViaVirtual, 'metaCategory');
assert.equal('boom!', postMetaCategoryLink.metadata().testValue);
});
it('Should fail when you try to add a non-existing link', function (done) {
let postId = PostCollection.insert({text: 'hello'});
try {
PostCollection.getLink(postId, 'comments').add('XXXXXXX');
} catch (e) {
assert.equal(e.error, 'not-found');
done();
}
})
});