<commit_before>'use strict';
var expect = require('chai').expect;
var BBPromise = require('bluebird');
var SubscriptionController = require('../../lib/subscription_controller');
var Model = require('hoist-model');
var mongoose = BBPromise.promisifyAll(Model._mongoose);
var config = require('config');

describe('SubscriptionController', function () {
  before(function () {
    return mongoose.connectAsync(config.get('Hoist.mongo.db'));
  });
  after(function () {
    return mongoose.disconnectAsync();
  });
  describe('constructor', function () {
    var _subscription;
    var _subscriptionModel;
    before(function () {
      return new Model.Subscription({
        _id: 'subscriptionId',
        application: 'testAppId',
        connector: 'connectorKey',
        endpoints: ['/Contacts', '/Invoices'],
        environment: 'test',
      }).saveAsync().then(function (sub) {
        _subscriptionModel = sub[0];
        _subscription = new SubscriptionController(sub[0]);
      });
    });
    after(function () {
      return Model.Subscription.removeAsync({});
    });

    it('sets the suscription attributes', function () {
      expect(_subscription._id).to.eql(_subscriptionModel._id);
      expect(_subscription.connector).to.eql(_subscriptionModel.connector);
      expect(_subscription.application).to.eql(_subscriptionModel.application);
      expect(_subscription.endpoints).to.have.members(_subscriptionModel.endpoints);
      expect(_subscription.environment).to.eql(_subscriptionModel.environment);
    });
    it('creates a get function', function () {
      expect(_subscription.get).to.exist;
    });
    it('creates a get function', function () {
      expect(_subscription.set).to.exist;
    });
  });
  describe('#GET', function () {
    describe('with no meta', function () {
      var _subscription;
      var _subscriptionModel;
      var _result;
      before(function () {
        return new Model.Subscription({
          _id: 'subscriptionId',
          application: 'testAppId',
          connector: 'connectorKey',
          endpoints: ['/Contacts', '/Invoices'],
          environment: 'test',
        }).saveAsync().then(function (sub) {
          _subscriptionModel = sub[0];
          _subscription = new SubscriptionController(sub[0]);
          _result = _subscription.get('fakeKey');

        });
      });
      after(function () {
        return Model.Subscription.removeAsync({});
      });
      it('returns null', function () {
        expect(_result).to.eql(null);
      });<commit_msg>fix to.exist test error<commit_after>'use strict';
var expect = require('chai').expect;
var BBPromise = require('bluebird');
var SubscriptionController = require('../../lib/subscription_controller');
var Model = require('hoist-model');
var mongoose = BBPromise.promisifyAll(Model._mongoose);
var config = require('config');

describe('SubscriptionController', function () {
  before(function () {
    return mongoose.connectAsync(config.get('Hoist.mongo.db'));
  });
  after(function () {
    return mongoose.disconnectAsync();
  });
  describe('constructor', function () {
    var _subscription;
    var _subscriptionModel;
    before(function () {
      return new Model.Subscription({
        _id: 'subscriptionId',
        application: 'testAppId',
        connector: 'connectorKey',
        endpoints: ['/Contacts', '/Invoices'],
        environment: 'test',
      }).saveAsync().then(function (sub) {
        _subscriptionModel = sub[0];
        _subscription = new SubscriptionController(sub[0]);
      });
    });
    after(function () {
      return Model.Subscription.removeAsync({});
    });

    it('sets the suscription attributes', function () {
      expect(_subscription._id).to.eql(_subscriptionModel._id);
      expect(_subscription.connector).to.eql(_subscriptionModel.connector);
      expect(_subscription.application).to.eql(_subscriptionModel.application);
      expect(_subscription.endpoints).to.have.members(_subscriptionModel.endpoints);
      expect(_subscription.environment).to.eql(_subscriptionModel.environment);
    });
    it('creates a get function on the subscription', function () {
      expect(typeof _subscription.get).to.eql('function');
    });
    it('creates a get function on the subscription', function () {
      expect(typeof _subscription.set).to.eql('function');
    });
  });
  describe('#GET', function () {
    describe('with no meta', function () {
      var _subscription;
      var _subscriptionModel;
      var _result;
      before(function () {
        return new Model.Subscription({
          _id: 'subscriptionId',
          application: 'testAppId',
          connector: 'connectorKey',
          endpoints: ['/Contacts', '/Invoices'],
          environment: 'test',
        }).saveAsync().then(function (sub) {
          _subscriptionModel = sub[0];
          _subscription = new SubscriptionController(sub[0]);
          _result = _subscription.get('fakeKey');

        });
      });
      after(function () {
        return Model.Subscription.removeAsync({});
      });
      it('returns null', function () {
        expect(_result).to.eql(null);
      });
{'fraction_non_alphanumeric': 0.14786821705426356, 'fraction_numerical': 0.0015503875968992248, 'mean_word_length': 3.1857258718572585, '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': '5005724', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1429, 'n_words': 259}