<commit_before>var assert = require('assert'),
    manyToManyFixture = require('../../support/fixtures/model/context.manyToMany.fixture'),
    Model = require('../../../lib/waterline/model');

describe('instance methods', function() {
  describe('association setters', function() {

    /////////////////////////////////////////////////////
    // TEST SETUP
    ////////////////////////////////////////////////////

    var model;

    before(function() {
      model = new Model(manyToManyFixture(), {});
    });


    /////////////////////////////////////////////////////
    // TEST METHODS
    ////////////////////////////////////////////////////

    it('should allow new associations to be added using the add function', function() {
      var person = new model({ name: 'foobar' });

      person.bars.add(1);
      assert(person.associations.bars.addModels.length === 1);
    });

    it('should allow new associations to be removed using the remove function', function() {
      var person = new model({ name: 'foobar' });

      person.bars.remove(1);
      assert(person.associations.bars.removeModels.length === 1);
    });

  });
});<commit_msg>Add unit tests on .add() and .remove()<commit_after>var assert = require('assert'),
    manyToManyFixture = require('../../support/fixtures/model/context.manyToMany.fixture'),
    Model = require('../../../lib/waterline/model');

describe('instance methods', function() {
  describe('association setters', function() {

    /////////////////////////////////////////////////////
    // TEST SETUP
    ////////////////////////////////////////////////////

    var model;

    before(function() {
      model = new Model(manyToManyFixture(), {});
    });


    /////////////////////////////////////////////////////
    // TEST METHODS
    ////////////////////////////////////////////////////

    it('should allow new associations to be added using the add function', function() {
      var person = new model({ name: 'foobar' });

      person.bars.add(1);
      assert(person.associations.bars.addModels.length === 1);
    });

    it('should allow new associations to be added using the add function and an array', function() {
      var person = new model({ name: 'foobar' });

      person.bars.add( [ 1, 2, 3 ] );
      assert(person.associations.bars.addModels.length === 3);
    });
    

    it('should allow new associations to be removed using the remove function', function() {
      var person = new model({ name: 'foobar' });

      person.bars.remove(1);
      assert(person.associations.bars.removeModels.length === 1);
    });

    it('should allow new associations to be removed using the remove function and an array', function() {
      var person = new model({ name: 'foobar' });

      person.bars.remove( [ 1, 2, 3 ] );
      assert(person.associations.bars.removeModels.length === 3);
    });
  });
});
{'fraction_non_alphanumeric': 0.27966689798750866, 'fraction_numerical': 0.005551700208188758, 'mean_word_length': 1.7121354656632173, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1443619', 'n_tokens_mistral': 744, 'n_tokens_neox': 694, 'n_words': 190}