<commit_before>if (typeof module === 'object') require('./setup');

testSuite('NProgress', function() {

  afterEach(function() {
    $("#nprogress").remove();
    NProgress.status = null;
  });

  it('.set(0) must render', function(done) {
    NProgress.set(0);
    assert.equal($("#nprogress").length, 1);
    assert.equal($("#nprogress .bar").length, 1);
    assert.equal($("#nprogress .peg").length, 1);
    assert.equal($("#nprogress .spinner").length, 1);
    done();
  });

  it('.set(0) must respect minimum', function() {
    NProgress.set(0);
    assert.equal(NProgress.status, NProgress.settings.minimum);
  });

  it('.configure() should work', function() {
    NProgress.configure({ minimum: 0.5 });
    assert.equal(NProgress.settings.minimum, 0.5);
  });

  it('.set(1) should appear and disappear', function(done) {
    NProgress.configure({ speed: 10 });
    NProgress.set(0).set(100);
    assert.equal($("#nprogress").length, 1);

    setTimeout(function() {
      assert.equal($("#nprogress").length, 0);
      done();
    }, 50);
  });
});<commit_msg>More tests.<commit_after>if (typeof module === 'object') require('./setup');

testSuite('NProgress', function() {

  afterEach(function() {
    $("#nprogress").remove();
    $('html').attr('class', '');
    NProgress.status = null;
  });

  describe('.set()', function() {
    it('.set(0) must render', function(done) {
      NProgress.set(0);
      assert.equal($("#nprogress").length, 1);
      assert.equal($("#nprogress .bar").length, 1);
      assert.equal($("#nprogress .peg").length, 1);
      assert.equal($("#nprogress .spinner").length, 1);
      done();
    });

    it('.set(1) should appear and disappear', function(done) {
      NProgress.configure({ speed: 10 });
      NProgress.set(0).set(1);
      assert.equal($("#nprogress").length, 1);

      setTimeout(function() {
        assert.equal($("#nprogress").length, 0);
        done();
      }, 70);
    });

    it('must respect minimum', function() {
      NProgress.set(0);
      assert.equal(NProgress.status, NProgress.settings.minimum);
    });

    it('must clamp to minimum', function() {
      NProgress.set(-100);
      assert.equal(NProgress.status, NProgress.settings.minimum);
    });

    it('must clamp to maximum', function() {
      NProgress.set(456);
      assert.equal(NProgress.status, null);
    });
  });

  // ----

  describe('.start()', function() {
    it('must render', function(done) {
      NProgress.start();
      assert.equal($("#nprogress").length, 1);
      done();
    });

    it('must respect minimum', function() {
      NProgress.start();
      assert.equal(NProgress.status, NProgress.settings.minimum);
    });
  });

  // ----

  describe('.done()', function() {
    it('must not render without start', function(done) {
      NProgress.done();
      assert.equal($("#nprogress").length, 0);
      done();
    });

    it('.done(true) must render', function(done) {
      NProgress.done(true);
      assert.equal($("#nprogress").length, 1);
      done();
    });
  });

  // ----

  describe('.inc()', function() {
    it('should render', function() {
      NProgress.inc();
      assert.equal($("#nprogress").length, 1);
    });

    it('should start with minimum', function() {
      NProgress.inc();
      assert.equal(NProgress.status, NProgress.settings.minimum);
    });

    it('should increment', function() {
      NProgress.start();
      var start = NProgress.status;

      NProgress.inc();
      assert.operator(NProgress.status, '>', start);
    });

    it('should never reach 1.0', function() {
      for (var i=0; i<100; ++i) { NProgress.inc(); }
      assert.operator(NProgress.status, '<', 1.0);
    });
  });

  // -----

  describe('.configure()', function() {
    it('should work', function() {
      NProgress.configure({ minimum: 0.5 });
      assert.equal(NProgress.settings.minimum, 0.5);
    });
  });
});
{'fraction_non_alphanumeric': 0.21395705521472394, 'fraction_numerical': 0.015593047034764827, 'mean_word_length': 2.9645390070921986, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '2039787', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1193, 'n_words': 219}