<commit_before>const YouTube = require('../index')
const Simulate = React.addons.TestUtils.Simulate
const render = React.addons.TestUtils.renderIntoDocument

describe('Addons - YouTube', function() {

  it ('passes through slugs as a video_id content field', function(done) {
    const slug = '0bRLtJHo0pI'
    const test = function({ video_id }) {
      video_id.should.equal(slug)
      done()
    }

    const component = render(<YouTube onChange={ test } />)

    component._onChange({ video_id: slug })
  })

  it ('can process undefined values', function(done) {
    const test = function({ video_id }) {
      video_id.should.equal('')
      done()
    }

    const component = render(<YouTube onChange={ test } />)

    component._onChange({ video_id: undefined })
  })

  describe('Extracting URLs', function() {
    const patterns = {
      shortcode: "http://youtu.be/dQw4w9WgXcQ",
      embed: "http://www.youtube.com/embed/dQw4w9WgXcQ",
      watch_query_string: "http://www.youtube.com/watch?v=dQw4w9WgXcQ",
      query_string: "http://www.youtube.com/?v=dQw4w9WgXcQ",
      v_url_parameter: "http://www.youtube.com/v/dQw4w9WgXcQ",
      embed_url_parameter: "http://www.youtube.com/e/dQw4w9WgXcQ",
      user_hash: "http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ",
      org_hash: "http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/0/dQw4w9WgXcQ",
      watch_extra_query_parameters: "http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ",
      extra_query_parameters: "http://www.youtube.com/?feature=player_embedded&v=dQw4w9WgXcQ"
    }

    for (let pattern in patterns) {
      it (`extracts the video id from a YouTube ${ pattern.split("_").join(" ") }`, function(done) {
        const url  = patterns[pattern]
        const test = function({ video_id }) {<commit_msg>use a better test parsing method<commit_after>const YouTube = require('../index')
const Simulate = React.addons.TestUtils.Simulate
const render = React.addons.TestUtils.renderIntoDocument

describe('Addons - YouTube', function() {

  it ('passes through slugs as a video_id content field', function(done) {
    const slug = '0bRLtJHo0pI'
    const test = function({ video_id }) {
      video_id.should.equal(slug)
      done()
    }

    const component = render(<YouTube onChange={ test } />)

    component._onChange({ video_id: slug })
  })

  it ('can process undefined values', function(done) {
    const test = function({ video_id }) {
      video_id.should.equal('')
      done()
    }

    const component = render(<YouTube onChange={ test } />)

    component._onChange({ video_id: undefined })
  })

  describe('Extracting URLs', function() {
    const patterns = {
      shortcode: "http://youtu.be/dQw4w9WgXcQ",
      embed: "http://www.youtube.com/embed/dQw4w9WgXcQ",
      watch_query_string: "http://www.youtube.com/watch?v=dQw4w9WgXcQ",
      query_string: "http://www.youtube.com/?v=dQw4w9WgXcQ",
      v_url_parameter: "http://www.youtube.com/v/dQw4w9WgXcQ",
      embed_url_parameter: "http://www.youtube.com/e/dQw4w9WgXcQ",
      user_hash: "http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ",
      org_hash: "http://www.youtube.com/sandalsResorts#p/c/54B8C800269D7C1B/0/dQw4w9WgXcQ",
      watch_extra_query_parameters: "http://www.youtube.com/watch?feature=player_embedded&v=dQw4w9WgXcQ",
      extra_query_parameters: "http://www.youtube.com/?feature=player_embedded&v=dQw4w9WgXcQ"
    }

    for (let pattern in patterns) {
      it (`extracts the video id from a YouTube ${ pattern.replace("_", " ") }`, function(done) {
        const url  = patterns[pattern]
        const test = function({ video_id }) {
{'fraction_non_alphanumeric': 0.14762165117550574, 'fraction_numerical': 0.019682886823400764, 'mean_word_length': 3.5623441396508726, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 18, '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': '6069858', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1322, 'n_words': 217}