From e983f0c9e1bc2a1e99a243d306506529116f8fea Mon Sep 17 00:00:00 2001 From: loay Date: Wed, 23 Aug 2017 20:58:28 -0400 Subject: [PATCH] Add test coverage for hasAndBelongsToMany --- test/relations.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/relations.test.js b/test/relations.test.js index a057d233..53808087 100644 --- a/test/relations.test.js +++ b/test/relations.test.js @@ -4092,6 +4092,24 @@ describe('relations', function() { }); }); + bdd.itIf(connectorCapabilities.deleteWithOtherThanId !== false, + 'should destroy all related instances', function(done) { + Article.create(function(err, article) { + if (err) return done(err); + article.tagNames.create({name: 'popular'}, function(err, t) { + if (err) return done(err); + article.tagNames.destroyAll(function(err) { + if (err) return done(err); + article.tagNames(true, function(err, list) { + if (err) return done(err); + list.should.have.length(0); + done(); + }); + }); + }); + }); + }); + it('should allow to add connection with instance', function(done) { Article.findOne(function(e, article) { TagName.create({name: 'awesome'}, function(e, tag) {