<commit_before>function flushRavenState() {
  cachedAuth = undefined;
  hasJSON = !isUndefined(window.JSON);
  globalServer = undefined;
  globalUser = undefined;
  globalProject = undefined;
  globalOptions = {
    logger: 'javascript',
    ignoreErrors: [],
    ignoreUrls: [],
    whitelistUrls: [],
    includePaths: [],
    tags: {}
  };
  Raven.uninstall();
}

var imageCache = [];
window.Image = function Image() {
  imageCache.push(this);
};

// window.console must be stubbed in for browsers that don't have it
if (typeof window.console === 'undefined') {
  console = {error: function(){}};
}

var SENTRY_DSN = 'http://abc@example.com:80/2';

function setupRaven() {
  Raven.config(SENTRY_DSN);
}


describe('globals', function() {
  beforeEach(function() {
    setupRaven();
    globalOptions.fetchContext = true;
  });

  afterEach(function() {
    flushRavenState();
  });

  it('should not have TraceKit on window', function() {
    assert.isUndefined(window.TraceKit);
  });

  it('should have a local TK', function() {
    assert.isObject(TK);
  });

  describe('getHttpData', function() {
    var data = getHttpData();

    it('should have a url', function() {
        assert.equal(data.url, window.location.href);
    });

    it('should have the user-agent header', function() {
      assert.equal(data.headers['User-Agent'], navigator.userAgent);
    });

    it('should have referer header when available', function() {
      // lol this test is awful
      if (window.document.referrer) {
        assert.equal(data.headers.Referer, window.document.referrer);
      } else {
        assert.isUndefined(data.headers.Referer);
      }
    });

  });

  describe('isUndefined', function() {
    it('should do as advertised', function() {
      assert.isTrue(isUndefined());
      assert.isFalse(isUndefined({}));
      assert.isFalse(isUndefined(''));
      assert.isTrue(isUndefined(undefined));
    });
  });

  describe('isFunction', function() {
    it('should do as advertised', function() {
      assert.isTrue(isFunction(function(){}));
      assert.isFalse(isFunction({}));
      assert.isFalse(isFunction(''));
      assert.isFalse(isFunction(undefined));
    });
  });

  describe('isSetup', function() {
    it('should return false with no JSON support', function() {
      globalServer = 'http://localhost/';
      hasJSON = false;
      assert.isFalse(isSetup());
    });

    it('should return false when Raven is not configured and write to console.error', function() {
      hasJSON = true;  // be explicit
      globalServer = undefined;
      this.sinon.stub(console, 'error');
      assert.isFalse(isSetup());
      assert.isTrue(console.error.calledOnce);
    });

    it('should return true when everything is all gravy', function() {
      hasJSON = true;
      setupRaven();
      assert.isTrue(isSetup());
    });
  });

  describe('getAuthQueryString', function() {
    it('should return a properly formatted string and cache it', function() {
      setupRaven();
      var expected = '?sentry_version=2.0&sentry_client=raven-js/@VERSION&sentry_key=abc';
      assert.strictEqual(getAuthQueryString(), expected);
      assert.strictEqual(cachedAuth, expected);
    });

    it('should return cached value when it exists', function() {
      cachedAuth = 'lol';
      assert.strictEqual(getAuthQueryString(), 'lol');
    });
  });

  describe('parseUri', function() {
    it('should do what it advertises', function() {
      var pieces = parseUri(SENTRY_DSN);
      assert.strictEqual(pieces.protocol, 'http');
      assert.strictEqual(pieces.user, 'abc');
      assert.strictEqual(pieces.port, '80');
      assert.strictEqual(pieces.path, '/2');<commit_msg>loltests<commit_after>function flushRavenState() {
  cachedAuth = undefined;
  hasJSON = !isUndefined(window.JSON);
  globalServer = undefined;
  globalUser = undefined;
  globalProject = undefined;
  globalOptions = {
    logger: 'javascript',
    ignoreErrors: [],
    ignoreUrls: [],
    whitelistUrls: [],
    includePaths: [],
    tags: {}
  };
  Raven.uninstall();
}

var imageCache = [];
window.Image = function Image() {
  imageCache.push(this);
};

// window.console must be stubbed in for browsers that don't have it
if (typeof window.console === 'undefined') {
  console = {error: function(){}};
}

var SENTRY_DSN = 'http://<EMAIL>@example.com:80/2';

function setupRaven() {
  Raven.config(SENTRY_DSN);
}


describe('globals', function() {
  beforeEach(function() {
    setupRaven();
    globalOptions.fetchContext = true;
  });

  afterEach(function() {
    flushRavenState();
  });

  it('should not have TraceKit on window', function() {
    assert.isUndefined(window.TraceKit);
  });

  it('should have a local TK', function() {
    assert.isObject(TK);
  });

  describe('getHttpData', function() {
    var data = getHttpData();

    it('should have a url', function() {
        assert.equal(data.url, window.location.href);
    });

    it('should have the user-agent header', function() {
      assert.equal(data.headers['User-Agent'], navigator.userAgent);
    });

    it('should have referer header when available', function() {
      // lol this test is awful
      if (window.document.referrer) {
        assert.equal(data.headers.Referer, window.document.referrer);
      } else {
        assert.isUndefined(data.headers.Referer);
      }
    });

  });

  describe('isUndefined', function() {
    it('should do as advertised', function() {
      assert.isTrue(isUndefined());
      assert.isFalse(isUndefined({}));
      assert.isFalse(isUndefined(''));
      assert.isTrue(isUndefined(undefined));
    });
  });

  describe('isFunction', function() {
    it('should do as advertised', function() {
      assert.isTrue(isFunction(function(){}));
      assert.isFalse(isFunction({}));
      assert.isFalse(isFunction(''));
      assert.isFalse(isFunction(undefined));
    });
  });

  describe('isSetup', function() {
    it('should return false with no JSON support', function() {
      globalServer = 'http://localhost/';
      hasJSON = false;
      assert.isFalse(isSetup());
    });

    it('should return false when Raven is not configured and write to console.error', function() {
      hasJSON = true;  // be explicit
      globalServer = undefined;
      this.sinon.stub(console, 'error');
      assert.isFalse(isSetup());
      assert.isTrue(console.error.calledOnce);
    });

    it('should return true when everything is all gravy', function() {
      hasJSON = true;
      setupRaven();
      assert.isTrue(isSetup());
    });
  });

  describe('getAuthQueryString', function() {
    it('should return a properly formatted string and cache it', function() {
      setupRaven();
      var expected = '?sentry_version=3&sentry_client=raven-js/@VERSION&sentry_key=abc';
      assert.strictEqual(getAuthQueryString(), expected);
      assert.strictEqual(cachedAuth, expected);
    });

    it('should return cached value when it exists', function() {
      cachedAuth = 'lol';
      assert.strictEqual(getAuthQueryString(), 'lol');
    });
  });

  describe('parseUri', function() {
    it('should do what it advertises', function() {
      var pieces = parseUri(SENTRY_DSN);
      assert.strictEqual(pieces.protocol, 'http');
      assert.strictEqual(pieces.user, 'abc');
      assert.strictEqual(pieces.port, '80');
      assert.strictEqual(pieces.path, '/2');
{'fraction_non_alphanumeric': 0.15560362309044207, 'fraction_numerical': 0.002027849128024875, 'mean_word_length': 3.382701421800948, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '2180453', 'n_tokens_mistral': 2257, 'n_tokens_neox': 2197, 'n_words': 471}