<commit_before>require.config
  baseUrl: '../lib'
  paths:
    hlf: '../dist'
    test: '../tests/js'

require [
  'jquery'
  'underscore'
  'test/base'
  'test/base-visual'
  'hlf/jquery.hlf.media-grid'
], ($, _) ->
  'use strict'

  if window.QUnit?
    {module, test} = QUnit

    module 'hlf.mediaGrid',
      beforeEach: ->
        @mg = $ """
          <div>
            <div class="js-mg-item"></div>
            <div class="js-mg-item"></div>
            <div class="js-mg-item"></div>
          </div>
          """
          .mediaGrid().mediaGrid()
  
    test '#_updateMetrics', (assert) ->
      {$el, $items} = @mg
      $el.add($items).css boxSizing: 'border-box'
      $el.css width: 620, padding: 10
      $items.css marginRight: 10, padding: 9, borderWidth: 1, width: 200, height: 200
      @mg._updateMetrics(on)
      assert.strictEqual @mg.metrics.gutter, 10,
        'It calculates gutter based on item margin sizes.'
      assert.strictEqual @mg.metrics.itemWidth, 200,
        "It uses the item's 'outerWidth' as item width."
      assert.strictEqual @mg.metrics.rowSize, 2,
        'It calculates row size based on item and wrap sizes.'
      assert.strictEqual @mg.metrics.colSize, 2,
        'It calculates column size based on row size.'

      $el.css width: 630
      @mg._updateMetrics(on)
      assert.strictEqual @mg.metrics.rowSize, 3,
        'It calculates row size based on item and wrap sizes.'
      assert.strictEqual @mg.selectByClass('sample').length, 1,
        'It cleans up after multiple hard updates.'
      return

    QUnit.start()
    return

  tests = []<commit_msg>Fix and clean up failing media-grid spec.<commit_after>require.config
  baseUrl: '../lib'
  paths:
    hlf: '../dist'
    test: '../tests/js'

require [
  'jquery'
  'underscore'
  'test/base'
  'test/base-visual'
  'hlf/jquery.hlf.media-grid'
], ($, _) ->
  'use strict'

  if window.QUnit?
    {module, test} = QUnit

    module 'hlf.mediaGrid',
      beforeEach: ->
        @mg = $ """
          <div>
            <div>
              <div class="js-mg-item"></div>
              <div class="js-mg-item"></div>
              <div class="js-mg-item"></div>
            </div>
          </div>
          """
          .appendTo('body') # Required for 'auto' width.
          .children('div').mediaGrid().mediaGrid()

      afterEach: ->
        @mg.$el.parent().remove()
  
    test '#_updateMetrics', (assert) ->
      {$el, $items} = @mg
      $el.add($items).css boxSizing: 'border-box'
      $el.css padding: 10

      $el.parent().css width: 610
      $items.css marginRight: 10, padding: 9, borderWidth: 1, width: 200, height: 200
      @mg._updateMetrics on
      assert.strictEqual @mg.metrics.gutter, 10,
        'It calculates gutter based on item margin sizes.'
      assert.strictEqual @mg.metrics.itemWidth, 200,
        "It uses the item's 'outerWidth' as item width."
      assert.strictEqual @mg.metrics.rowSize, 2,
        'It calculates row size based on item and wrap sizes.'
      assert.strictEqual @mg.metrics.colSize, 2,
        'It calculates column size based on row size.'

      $el.parent().css width: 620
      @mg._updateMetrics on
      assert.strictEqual @mg.metrics.rowSize, 3,
        'It calculates row size based on item and wrap sizes.'
      assert.strictEqual @mg.selectByClass('sample').length, 1,
        'It cleans up after multiple hard updates.'
      return

    QUnit.start()
    return

  tests = []
{'fraction_non_alphanumeric': 0.1455385503898354, 'fraction_numerical': 0.01559341611319665, 'mean_word_length': 2.172161172161172, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 28, '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': '1331223', 'n_tokens_mistral': 1173, 'n_tokens_neox': 1088, 'n_words': 292}