<commit_before>/**
 * .reel Unit Tests
 */
(function($){

  module('Rendering', reel_test_module_routine);

  test( 'The DOM element gets its own generated ID if it doesn\'t currently has one', function(){
    expect(3);
    var
      $reel_with_id= $('#image').reel(),
      $reel_without_id= $('.no_id:first').reel()

    // Given ID attribute
    equal( $reel_with_id.attr('id'), 'image');

    // The generated ID consists of "reel-" followed by a timestamp
    equal( $reel_without_id.attr('id').substr(0, 5), 'reel-');
    equal( Math.floor(+$reel_without_id.attr('id').substr(5) / 10000), Math.floor(+new Date() / 10000));
  });

  test( 'Overlay: is created with proper ID', function(){
    expect(1);
    var
      suffix= '-abc',
      $reel= $('#image').reel({ suffix: suffix }),
      $overlay= $('#image' + suffix)

    ok( $overlay.length, 'Has the right ID (original image ID + `suffix`)' );
  });

  test( 'Overlay: has the proper `reel-overlay` class', function(){
    expect(1);
    var
      $reel= $('#image').reel(),
      $overlay= $('#image-reel')

    ok( $overlay.hasClass('reel-overlay'), 'Has the class');
  });

  asyncTest( 'Indicator: is sticked to the bottom edge of the container no matter its size', function(){
    expect(1);
    var
      $reel= $('#image').reel({ indicator: 5 })

    $(document).bind('loaded.test', function(e){
      equiv( $('#image-reel .reel-indicator').css('bottom'), 0 );
      start();
    });
  });

  $.each([5, 10, 30], function(index, sample){
    asyncTest( 'Indicator: `indicator` option value ('+sample+')is the height of the indicator', function(){
      expect(2);
      var
        size= sample,
        $reel= $('#image').reel({ indicator: size, speed: 2 }),
        portion= Math.round($('#image').width() / 36),
        $indicator= $('#image-reel .reel-indicator')

      $(document).bind('loaded.test', function(){
        equiv( $indicator.css('width'), portion );
        equiv( $indicator.css('height'), size );
        start();
      });
    });
  });

  asyncTest( 'Indicator: is sticked to the bottom left corner when on min frame (1)', function(){
    expect(2);
    var
      size= 10,
      $reel= $('#image').reel({
        indicator: size,
        frames: 36,
        frame: 1
      }),
      $indicator= $('#image-reel .reel-indicator');

    $(document).bind('loaded.test', function(){
      equal( $reel.data('frame'), 1, 'It is frame number 1');
      equiv( $indicator.css('left'), '0px' );
      start();
    });
  });

  test( 'Indicator: is sticked to the bottom right corner when on max frame (36)', function(){
    expect(1);
    var
      $image= $('#image'),
      weight= $image.width() / 36,
      $reel= $image.reel({ indicator: 10 }),
      width= parseInt($reel.css('width')),
      $indicator= $('#image-reel .reel-indicator');

    /*
    As the indicator indicates the beginning of the frame and not its end we need to simulate
    the "end" by providing a fraction as near to 1 as possible, but not quite
    */
    $reel.trigger('fractionChange', [0.9999]);

    equiv( $indicator.css('left'), (width - size) + 'px' );
    start();
  });

  asyncTest( 'Indicator: reacts on frame change', function(){
    expect(1);
    var
      $reel= $('#image').reel({ indicator: 20, frame: 1 }),
      before= $('#image-reel .reel-indicator').css('left');

      $reel.trigger('frameChange', 5);
      $reel.one('frameChange.test', function(){
        var
          after= $('#image-reel .reel-indicator').css('left');

        ok( before != after, 'Position change after frame change' );
        start();
      $(document).bind('loaded.test', function(){
      });
    })
  });

  test( 'Indicator: Custom style may be applied to indicator via `.reel-indicator`', function(){
    expect(2);
    var
      $reel= $('#image').reel({ indicator: 10 }),
      $indicator= $('#image-reel .reel-indicator');

    $indicator.css({         // This may as well be done in external CSS
      background: '#fff',
      opacity: 0.5<commit_msg>Checking indicator's position is no longer asynchronous task.<commit_after>/**
 * .reel Unit Tests
 */
(function($){

  module('Rendering', reel_test_module_routine);

  test( 'The DOM element gets its own generated ID if it doesn\'t currently has one', function(){
    expect(3);
    var
      $reel_with_id= $('#image').reel(),
      $reel_without_id= $('.no_id:first').reel()

    // Given ID attribute
    equal( $reel_with_id.attr('id'), 'image');

    // The generated ID consists of "reel-" followed by a timestamp
    equal( $reel_without_id.attr('id').substr(0, 5), 'reel-');
    equal( Math.floor(+$reel_without_id.attr('id').substr(5) / 10000), Math.floor(+new Date() / 10000));
  });

  test( 'Overlay: is created with proper ID', function(){
    expect(1);
    var
      suffix= '-abc',
      $reel= $('#image').reel({ suffix: suffix }),
      $overlay= $('#image' + suffix)

    ok( $overlay.length, 'Has the right ID (original image ID + `suffix`)' );
  });

  test( 'Overlay: has the proper `reel-overlay` class', function(){
    expect(1);
    var
      $reel= $('#image').reel(),
      $overlay= $('#image-reel')

    ok( $overlay.hasClass('reel-overlay'), 'Has the class');
  });

  asyncTest( 'Indicator: is sticked to the bottom edge of the container no matter its size', function(){
    expect(1);
    var
      $reel= $('#image').reel({ indicator: 5 })

    $(document).bind('loaded.test', function(e){
      equiv( $('#image-reel .reel-indicator').css('bottom'), 0 );
      start();
    });
  });

  $.each([5, 10, 30], function(index, sample){
    asyncTest( 'Indicator: `indicator` option value ('+sample+')is the height of the indicator', function(){
      expect(2);
      var
        size= sample,
        $reel= $('#image').reel({ indicator: size, speed: 2 }),
        portion= Math.round($('#image').width() / 36),
        $indicator= $('#image-reel .reel-indicator')

      $(document).bind('loaded.test', function(){
        equiv( $indicator.css('width'), portion );
        equiv( $indicator.css('height'), size );
        start();
      });
    });
  });

  asyncTest( 'Indicator: is sticked to the bottom left corner when on min frame (1)', function(){
    expect(2);
    var
      size= 10,
      $reel= $('#image').reel({
        indicator: size,
        frames: 36,
        frame: 1
      }),
      $indicator= $('#image-reel .reel-indicator');

    $(document).bind('loaded.test', function(){
      equal( $reel.data('frame'), 1, 'It is frame number 1');
      equiv( $indicator.css('left'), '0px' );
      start();
    });
  });

  test( 'Indicator: is sticked to the bottom right corner when on max frame (36)', function(){
    expect(1);
    var
      $image= $('#image'),
      weight= $image.width() / 36,
      $reel= $image.reel({ indicator: 10 }),
      width= parseInt($reel.css('width')),
      $indicator= $('#image-reel .reel-indicator');

    // As the indicator indicates the beginning of the frame and not its end we need to simulate
    // the "end" by providing a fraction as near to 1 as possible, but not quite
    $reel.trigger('fractionChange', [0.9999]);

    equiv( $indicator.css('left'), Math.round(width - weight) + 'px' );
  });

  asyncTest( 'Indicator: reacts on frame change', function(){
    expect(1);
    var
      $reel= $('#image').reel({ indicator: 20, frame: 1 }),
      before= $('#image-reel .reel-indicator').css('left');

      $reel.trigger('frameChange', 5);
      $reel.one('frameChange.test', function(){
        var
          after= $('#image-reel .reel-indicator').css('left');

        ok( before != after, 'Position change after frame change' );
        start();
      $(document).bind('loaded.test', function(){
      });
    })
  });

  test( 'Indicator: Custom style may be applied to indicator via `.reel-indicator`', function(){
    expect(2);
    var
      $reel= $('#image').reel({ indicator: 10 }),
      $indicator= $('#image-reel .reel-indicator');

    $indicator.css({         // This may as well be done in external CSS
      background: '#fff',
      opacity: 0.5
{'fraction_non_alphanumeric': 0.18999382334774553, 'fraction_numerical': 0.015071031500926499, 'mean_word_length': 2.864439140811456, 'pattern_counts': {'":': 0, '<': 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': '775311', 'n_tokens_mistral': 2648, 'n_tokens_neox': 2518, 'n_words': 727}