<commit_before>define([
  'common/collections/visitors-realtime',
  'extensions/collections/collection'
],
function (VisitorsRealtimeCollection, Collection) {
  describe("VisitorsRealtimeCollection", function () {

    beforeEach(function() {
      jasmine.Clock.useMock();
      spyOn(VisitorsRealtimeCollection.prototype, "fetch");
      spyOn(Collection.prototype, "fetch");
    });

    it("is created with the correct query parameters", function () {
      var collection = new VisitorsRealtimeCollection(
        { 'data' : [] },
        { 'numTwoMinPeriodsToQuery': 60 }
      );
      var params = collection.queryParams();
      expect(params.sort_by).toEqual("_timestamp:descending");
      expect(params.limit).toEqual(60);
    });

    it("parses string data into float format", function () {
      var collection = new VisitorsRealtimeCollection({
          'data': [
            {
              _timestamp: "2002-03-01T00:00:03+00:00",
              unique_visitors: '100'
            },
            {
              _timestamp: "2002-03-01T00:00:00+00:00",
              unique_visitors: '120'
            }
          ]
      }, { 'parse': true } );
      expect(collection.first().get('values').first().get('_timestamp').format()).toEqual("2002-03-01T00:00:00+00:00");
      expect(collection.first().get('values').first().get('unique_visitors')).toEqual(120);
      expect(collection.first().get('values').last().get('unique_visitors')).toEqual(100);
    });

    it("auto-updates on the client", function () {
      jasmine.clientOnly(function () {
        var collection = new VisitorsRealtimeCollection();
        expect(collection.fetch).not.toHaveBeenCalled();
        jasmine.Clock.tick(120 * 1000 - 1);
        expect(collection.fetch).not.toHaveBeenCalled();
        jasmine.Clock.tick(1);
        expect(collection.fetch).toHaveBeenCalled();
      });
    });

    it("does not auto-update on the server", function () {
      jasmine.serverOnly(function () {
        var collection = new VisitorsRealtimeCollection();
        expect(collection.fetch).not.toHaveBeenCalled();
        jasmine.Clock.tick(120 * 1000);
        expect(collection.fetch).not.toHaveBeenCalled();
      });
    });

    it("sets cache headers correctly", function () {
      var collection = new VisitorsRealtimeCollection();
      collection.fetch.andCallThrough();
      collection.fetch();
      expect(Collection.prototype.fetch).toHaveBeenCalled();
      var args = Collection.prototype.fetch.argsForCall[0][0];
      expect(args).toEqual({
        headers: {"cache-control": "max-age=120"}
      });
    });
  });
});<commit_msg>Fixing lint errors.<commit_after>define([
  'common/collections/visitors-realtime',
  'extensions/collections/collection'
],
function (VisitorsRealtimeCollection, Collection) {
  describe('VisitorsRealtimeCollection', function () {

    beforeEach(function () {
      jasmine.Clock.useMock();
      spyOn(VisitorsRealtimeCollection.prototype, 'fetch');
      spyOn(Collection.prototype, 'fetch');
    });

    it('is created with the correct query parameters', function () {
      var collection = new VisitorsRealtimeCollection(
        { 'data' : [] },
        { 'numTwoMinPeriodsToQuery': 60 }
      );
      var params = collection.queryParams();
      expect(params.sort_by).toEqual('_timestamp:descending');
      expect(params.limit).toEqual(60);
    });

    it('parses string data into float format', function () {
      var collection = new VisitorsRealtimeCollection({
          'data': [
            {
              _timestamp: '2002-03-01T00:00:03+00:00',
              unique_visitors: '100'
            },
            {
              _timestamp: '2002-03-01T00:00:00+00:00',
              unique_visitors: '120'
            }
          ]
      }, { 'parse': true });
      expect(collection.first().get('values').first().get('_timestamp').format()).toEqual('2002-03-01T00:00:00+00:00');
      expect(collection.first().get('values').first().get('unique_visitors')).toEqual(120);
      expect(collection.first().get('values').last().get('unique_visitors')).toEqual(100);
    });

    it('auto-updates on the client', function () {
      jasmine.clientOnly(function () {
        var collection = new VisitorsRealtimeCollection();
        expect(collection.fetch).not.toHaveBeenCalled();
        jasmine.Clock.tick(120 * 1000 - 1);
        expect(collection.fetch).not.toHaveBeenCalled();
        jasmine.Clock.tick(1);
        expect(collection.fetch).toHaveBeenCalled();
      });
    });

    it('does not auto-update on the server', function () {
      jasmine.serverOnly(function () {
        var collection = new VisitorsRealtimeCollection();
        expect(collection.fetch).not.toHaveBeenCalled();
        jasmine.Clock.tick(120 * 1000);
        expect(collection.fetch).not.toHaveBeenCalled();
      });
    });

    it('sets cache headers correctly', function () {
      var collection = new VisitorsRealtimeCollection();
      collection.fetch.andCallThrough();
      collection.fetch();
      expect(Collection.prototype.fetch).toHaveBeenCalled();
      var args = Collection.prototype.fetch.argsForCall[0][0];
      expect(args).toEqual({
        headers: {'cache-control': 'max-age=120'}
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.15409401061410158, 'fraction_numerical': 0.03449583017437453, 'mean_word_length': 2.9031065088757395, 'pattern_counts': {'":': 1, '<': 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': '5104194', 'n_tokens_mistral': 1602, 'n_tokens_neox': 1495, 'n_words': 224}