<commit_before>define([
  'extensions/views/visitors-realtime',
  'extensions/collections/collection'
],
function (VisitorsRealtimeView, Collection) {
  describe("VisitorsRealtimeView", function () {
    it("renders a number", function () {
      var view = new VisitorsRealtimeView({
        collection: new Collection([{
          "unique_visitors": 10
        }])
      });

      jasmine.renderView(view, function () {
        expect(view.$el.html()).toEqual(
          '<strong>10</strong> Users online now'
        )
      })
    });

    it("renders singular if one user", function () {
      var view = new VisitorsRealtimeView({
        collection: new Collection([{
          "unique_visitors": 1
        }])
      });

      jasmine.renderView(view, function () {
        expect(view.$el.html()).toEqual(
          '<strong>1</strong> User online now'
        )
      })
    });

    describe('interpolating numbers', function () {
      beforeEach(function() {
        jasmine.Clock.useMock();

      });

      it("interpolates from previous to latest entry on first render", function () {
        var collection = new Collection([
          { "unique_visitors": 34 },
          { "unique_visitors": 10 }
        ]);
        var view = new VisitorsRealtimeView({
          collection: collection
        });
        jasmine.renderView(view, function () {
          collection.trigger('reset');
          expect(view.$el.find('strong')).toHaveHtml('10');
          jasmine.Clock.tick(view.updateInterval);
          // first tick
          expect(view.$el.find('strong')).toHaveHtml('11');
          jasmine.Clock.tick(view.updateInterval);
          // second tick
          expect(view.$el.find('strong')).toHaveHtml('12');
          jasmine.Clock.tick(view.updateInterval * 22);
          // reached the new value
          expect(view.$el.find('strong')).toHaveHtml('34');
          jasmine.Clock.tick(view.updateInterval * 10);
          // nothing happens, new value was already reached
          expect(view.$el.find('strong')).toHaveHtml('34');
        });
      });

      it("shouldn't blow up if there is only one item in a collection", function () {
        var collection = new Collection([
          { "unique_visitors": 34 }
        ]);
        var view = new VisitorsRealtimeView({
          collection: collection
        });
        jasmine.renderView(view, function () {
          collection.trigger('reset');
        });
      });
    });

    it("renders nothing when there's no data", function () {
      var view = new VisitorsRealtimeView({
        collection: new Collection([])
      });

      jasmine.renderView(view, function () {
        expect(view.$el.html()).toEqual('');
      });
    })
  })
});<commit_msg>Fix the tests<commit_after>define([
  'extensions/views/visitors-realtime',
  'extensions/collections/collection'
],
function (VisitorsRealtimeView, Collection) {
  describe("VisitorsRealtimeView", function () {
    it("renders a number", function () {
      var view = new VisitorsRealtimeView({
        collection: new Collection([{
          "unique_visitors": 10
        }])
      });

      jasmine.renderView(view, function () {
        expect(view.$el.html()).toEqual(
          '<strong>10</strong> <p>Users online now</p>'
        )
      })
    });

    it("renders singular if one user", function () {
      var view = new VisitorsRealtimeView({
        collection: new Collection([{
          "unique_visitors": 1
        }])
      });

      jasmine.renderView(view, function () {
        expect(view.$el.html()).toEqual(
          '<strong>1</strong> <p>User online now</p>'
        )
      })
    });

    describe('interpolating numbers', function () {
      beforeEach(function() {
        jasmine.Clock.useMock();

      });

      it("interpolates from previous to latest entry on first render", function () {
        var collection = new Collection([
          { "unique_visitors": 34 },
          { "unique_visitors": 10 }
        ]);
        var view = new VisitorsRealtimeView({
          collection: collection
        });
        jasmine.renderView(view, function () {
          collection.trigger('reset');
          expect(view.$el.find('strong')).toHaveHtml('10');
          jasmine.Clock.tick(view.updateInterval);
          // first tick
          expect(view.$el.find('strong')).toHaveHtml('11');
          jasmine.Clock.tick(view.updateInterval);
          // second tick
          expect(view.$el.find('strong')).toHaveHtml('12');
          jasmine.Clock.tick(view.updateInterval * 22);
          // reached the new value
          expect(view.$el.find('strong')).toHaveHtml('34');
          jasmine.Clock.tick(view.updateInterval * 10);
          // nothing happens, new value was already reached
          expect(view.$el.find('strong')).toHaveHtml('34');
        });
      });

      it("shouldn't blow up if there is only one item in a collection", function () {
        var collection = new Collection([
          { "unique_visitors": 34 }
        ]);
        var view = new VisitorsRealtimeView({
          collection: collection
        });
        jasmine.renderView(view, function () {
          collection.trigger('reset');
        });
      });
    });

    it("renders nothing when there's no data", function () {
      var view = new VisitorsRealtimeView({
        collection: new Collection([])
      });

      jasmine.renderView(view, function () {
        expect(view.$el.html()).toEqual('');
      });
    })
  })
});
{'fraction_non_alphanumeric': 0.1477725461789207, 'fraction_numerical': 0.009416877942774357, 'mean_word_length': 2.186959030582804, 'pattern_counts': {'":': 10, '<': 15, '<?xml version=': 0, '>': 15, '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': '3315229', 'n_tokens_mistral': 1557, 'n_tokens_neox': 1496, 'n_words': 308}