<commit_before>
'use strict';

var Analytics = require('@segment/analytics.js-core').constructor;
var integration = require('@segment/analytics.js-integration');
var sandbox = require('@segment/clear-env');
var tester = require('@segment/analytics.js-integration-tester');
var Outbound = require('../lib/');

describe('Outbound', function() {
  var analytics;
  var outbound;
  var options = {
    publicApiKey: '<KEY>'
  };

  beforeEach(function() {
    analytics = new Analytics();
    outbound = new Outbound(options);
    analytics.use(Outbound);
    analytics.use(tester);
    analytics.add(outbound);
  });

  afterEach(function() {
    analytics.restore();
    analytics.reset();
    sandbox();
  });

  it('should have the right settings', function() {
    analytics.compare(Outbound, integration('Outbound')
      .global('outbound')
      .option('publicApiKey', ''));
  });

  describe('before loading', function() {
    beforeEach(function() {
      analytics.stub(outbound, 'load');
    });

    describe('#initialize', function() {
      it('should create initialize outbound', function() {
        analytics.assert(!window.outbound);
        analytics.initialize();
        analytics.assert(window.outbound);
      });

      it('should extend window.outbound with methods', function() {
        var methods = [
          'identify',
          'track',
          'registerApnsToken',
          'registerGcmToken',
          'disableApnsToken',
          'disableGcmToken',
          'hasIdentified'
        ];
        for (var i = 0; i < methods.length; i++) {
          analytics.assert(window.outbound.hasOwnProperty(methods[i]));
        }<commit_msg>Stop window.outbound from leaking across test runs<commit_after>
'use strict';

var Analytics = require('@segment/analytics.js-core').constructor;
var integration = require('@segment/analytics.js-integration');
var sandbox = require('@segment/clear-env');
var tester = require('@segment/analytics.js-integration-tester');
var Outbound = require('../lib/');

describe('Outbound', function() {
  var analytics;
  var outbound;
  var options = {
    publicApiKey: '<KEY>'
  };

  beforeEach(function() {
    analytics = new Analytics();
    outbound = new Outbound(options);
    analytics.use(Outbound);
    analytics.use(tester);
    analytics.add(outbound);
  });

  afterEach(function() {
    analytics.restore();
    analytics.reset();
    outbound.reset();
    sandbox();
  });

  it('should have the right settings', function() {
    analytics.compare(Outbound, integration('Outbound')
      .global('outbound')
      .option('publicApiKey', ''));
  });

  describe('before loading', function() {
    beforeEach(function() {
      analytics.stub(outbound, 'load');
    });

    describe('#initialize', function() {
      it('should create initialize outbound', function() {
        analytics.assert(!window.outbound);
        analytics.initialize();
        analytics.assert(window.outbound);
      });

      it('should extend window.outbound with methods', function() {
        analytics.initialize();
        var methods = [
          'identify',
          'track',
          'registerApnsToken',
          'registerGcmToken',
          'disableApnsToken',
          'disableGcmToken',
          'hasIdentified'
        ];
        for (var i = 0; i < methods.length; i++) {
          analytics.assert(window.outbound.hasOwnProperty(methods[i]));
        }
{'fraction_non_alphanumeric': 0.15359953366365492, 'fraction_numerical': 0.0005829204313611193, 'mean_word_length': 3.047169811320755, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '1633994', 'n_tokens_mistral': 978, 'n_tokens_neox': 986, 'n_words': 190}