<commit_before>import { debounce, format, parents, parseTpl } from '../src/utils'

/**
 * Test Parents
 */

describe('parents', () => {
  test('available', () => {
    const container = document.createElement('div')

    container.setAttribute('class', 'jest-test')
    document.body.appendChild(container)

    expect(parents(container, 'jest-test')).toBe(container)
  })

  test('not available', () => {
    const container = document.createElement('div')

    expect(parents(container, 'jest-test')).toBe(null)
  })
})

/**
 * Test ParseTPL
 */

describe('parseTpl', () => {
  test('do nothing with missing value', () => {
    // eslint-disable-next-line no-template-curly-in-string
    expect(parseTpl('foo-${bar}-baz', {})).toBe('foo-${bar}-baz')
  })

  test('use the fallback with missing value', () => {
    // eslint-disable-next-line no-template-curly-in-string
    expect(parseTpl('foo-${bar}-baz', {}, '???')).toBe('foo-???-baz')
  })

  test('parse single value', () => {
    // eslint-disable-next-line no-template-curly-in-string
    expect(parseTpl('foo-${bar}-baz', { bar: '!!!' })).toBe('foo-!!!-baz')
  })

  test('parse multiple values', () => {
    // eslint-disable-next-line no-template-curly-in-string
    expect(parseTpl('foo-${bar}-baz-${qux}', { bar: '!!!', qux: '???' })).toBe(
      'foo-!!!-baz-???'
    )<commit_msg>test: :white_check_mark: Update Parents Test<commit_after>import { debounce, format, parents, parseTpl } from '../src/utils'

/**
 * Test Parents
 */

describe('parents', () => {
  const wrapper = document.createElement('div')
  const container = document.createElement('div')

  wrapper.appendChild(container)
  document.body.appendChild(wrapper)

  test('itself', () => {
    const target = document.createElement('div')

    target.setAttribute('class', 'jest-test')
    container.appendChild(target)

    expect(parents(target, 'jest-test')).toBe(target)
  })

  test('ancestor', () => {
    const target = document.createElement('div')

    wrapper.setAttribute('class', 'jest-test')
    container.appendChild(target)

    expect(parents(target, 'jest-test')).toBe(wrapper)
  })

  test('not available', () => {
    const target = document.createElement('div')

    wrapper.removeAttribute('class')
    container.appendChild(target)

    expect(parents(target, 'jest-test')).toBe(null)
  })
})

/**
 * Test ParseTPL
 */

describe('parseTpl', () => {
  test('do nothing with missing value', () => {
    // eslint-disable-next-line no-template-curly-in-string
    expect(parseTpl('foo-${bar}-baz', {})).toBe('foo-${bar}-baz')
  })

  test('use the fallback with missing value', () => {
    // eslint-disable-next-line no-template-curly-in-string
    expect(parseTpl('foo-${bar}-baz', {}, '???')).toBe('foo-???-baz')
  })

  test('parse single value', () => {
    // eslint-disable-next-line no-template-curly-in-string
    expect(parseTpl('foo-${bar}-baz', { bar: '!!!' })).toBe('foo-!!!-baz')
  })

  test('parse multiple values', () => {
    // eslint-disable-next-line no-template-curly-in-string
    expect(parseTpl('foo-${bar}-baz-${qux}', { bar: '!!!', qux: '???' })).toBe(
      'foo-!!!-baz-???'
    )
{'fraction_non_alphanumeric': 0.22570433681544794, 'fraction_numerical': 0.0, 'mean_word_length': 3.6814814814814816, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 20, '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': '2190164', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1041, 'n_words': 155}